次のデータベース スキーマがあります。
私はこのようなことができるようにしたい:
dog.head << Feature.new(...)
dog.tail << Feature.new(...)
私は Rails を初めて使用するので、何を書いているのか 100% 確信できるとは限りませんが、次の Dog クラスの宣言を試みましたが、失敗しました :) :
class Dog < ActiveRecord::Base
has_many :features, :through=>:dog_features
has_many :head_features, :through=>:dog_features, :class_name=>'Feature', :conditions=>{:group=>1}
has_many :tail_features, :through=>:dog_features, :class_name=>'Feature', :conditions=>{:group=>2}
end