Guest User

Untitled

a guest
Jun 24th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. # image.rb
  2. class Image < ActiveRecord
  3. has_many :comments, :as => :commentable
  4. end
  5.  
  6. # post.rb
  7. class Post < ActiveRecord
  8. has_many :comments, :as => :commentable
  9. end
  10.  
  11. # comment.rb
  12. class Comment < ActiveRecord
  13. belongs_to :commentable, :polymorphic => true
  14. end
  15.  
  16. # config/routes.rb
  17. resources :posts do
  18. resources comments
  19. end
  20.  
  21. resources :images do
  22. resources :comments
  23. end
Add Comment
Please, Sign In to add comment