ISSUE:
The host has 3 ip addresses on two networks (#62 is repeated)
How do I get host.networks to return only the two networks?

>> host
=> #<NetworkHost id: 923, name: "ota-app1", os_id: 1, feature_id: nil,
description: nil, created_at: "2010-05-18 19:05:49", updated_at:
"2010-05-18 19:05:49", ip_id: nil, server_id: 5, service_tag: nil,
location_id: nil, rack: nil, space: nil, net_profile_id: 77>
>> host.ip_addresses.size
=> 3
>> host.networks
=> [#<Network id: 62, name: "SCTCarrier990 Production Network", ip:
"192.168.110.0", ...l>,
    #<Network id: 62, name: "SCTCarrier990 Production Network", ip:
"192.168.110.0", ...>,
        #<Network id: 63, name: "SCTCarrier990 IP Profile Network3", ip:
"10.10.110.0", ...>]
>> host.networks.size
=> 3

## networks model
class Network < ActiveRecord::Base
  has_many :ip_addresses, :dependent => :destroy
  has_many :network_hosts, :through => :ip_addresses

## network_hosts model
class NetworkHost < ActiveRecord::Base

  has_many :ip_addresses, :dependent => :destroy
  has_many :networks, :through => :ip_addresses

## ip_addresses model
class IpAddress < ActiveRecord::Base
 
attr_accessible :name, :ip, :logical_interface_name_id, :network_host_id, 
:network_id, :is_entry_point, :is_gateway, :mac

  belongs_to :network_host
  belongs_to :network

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to