Guest User

Untitled

a guest
Jun 24th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. class Like < ActiveRecord::Base
  2.  
  3. belongs_to :likeable, :polymorphic => true
  4. belongs_to :profile
  5.  
  6. end
  7.  
  8. class Comment < ActiveRecord::Base
  9. #existing associations
  10. belongs_to :commentable, :polymorphic => true
  11. belongs_to :profile
  12.  
  13. # need to associate through likeable_id/likeable_type
  14. end
  15.  
  16. class Profile < ActiveRecord::Base
  17. #...
  18. has_many :likes
  19.  
  20. #need to associate to liked_comments
  21.  
  22. end
Add Comment
Please, Sign In to add comment