ホスト レコード (id、hostname、netid) を持つテーブルと、2 つのルート間の接続を表すルーティング接続を持つテーブル (id、src_id、src_ip、dst_id、dst_ip) をモデル化しようとしています。
ホストのすべてのルーティング レコードを取得し、(ホスト名を取得できるように) ホスト テーブルを :include しようとすると、ルーティング レコードのみが取得されます。私は何を間違っていますか?
class Host < ActiveRecord::Base
has_many :routes
end
class Route < ActiveRecord::Base
belongs_to :srchost, :class_name => 'Host', :foreign_key => 'src_id'
belongs_to :dsthost, :class_name => 'Host', :foreign_key => 'dst_id'
end
x = Route.where(:src_id => host).includes(:srchost, :dsthost)
puts x.inspect