Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. @specific_feeling_posts = @posts.feeling.where(:feeling => "happy")
  2.  
  3. class Post < ActiveRecord::Base
  4. has_many :feelingships
  5. has_many :feelings, :through => :feelingships
  6. belongs_to :user
  7. end
  8.  
  9. class Feeling < ActiveRecord::Base
  10. has_many :feelingships
  11. has_many :posts, :through => :feelingships
  12. end
  13.  
  14. class Feelingship < ActiveRecord::Base
  15. belongs_to :post
  16. belongs_to :feeling
  17. end
  18.  
  19. @happy_posts = Post.joins(:feelings).where("feelings.title = ?", "happy")
  20.  
  21. @specific_feelings_post=Post.join(:feelings).where("feelings.title= ?","specific_feeling")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement