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
=> 3host.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