0
我有一個名爲@posts的帖子數組。帖子模型has_many:感情:通過=>:感情。Rails 3:數據庫調用has_many:通過關係
如何獲取帖子數組並將其縮小到只有具有特定感覺的帖子?
我嘗試下面的代碼,但它不工作:(
@specific_feeling_posts = @posts.feeling.where(:feeling => "happy")
模型
class Post < ActiveRecord::Base
has_many :feelingships
has_many :feelings, :through => :feelingships
belongs_to :user
end
class Feeling < ActiveRecord::Base
has_many :feelingships
has_many :posts, :through => :feelingships
end
class Feelingship < ActiveRecord::Base
belongs_to :post
belongs_to :feeling
end