I have an array of posts called @posts. Post model has_many :feelings :through => :feelingships.
How do I take the array of posts and narrow them it down to only the posts with a specific feeling?
I tried the code below but it doesn’t work 🙁
@specific_feeling_posts = @posts.feeling.where(:feeling => "happy")
Models
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
That should work.