0
如果我建立了以下模型,是否在Authorship表中添加属性foo,这是特定于该关系的属性,而不是其他属性?如何在多对多表中发布和访问信息
class Author < ActiveRecord::Base
has_many :authorships
has_many :books, :through => :authorships
end
class Book < ActiveRecord::Base
has_many :authorships
has_many :authors, :through => :authorships
end
class Authorship < ActiveRecord::Base
attr_accessible :foo
belongs_to :author
belongs_to :book
end
什么查询会返回:foo属性,还是有更好的方法呢?
我已经完成了迁移,我只是不确定如何实际访问这些信息,或者如果这是存储信息的正确方法。您的回答提供了我需要的所有清晰度,谢谢! – Sean 2013-04-29 21:01:53