如果我设置了以下模型,这是在 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 属性,或者有更好的方法吗?