Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User
- has_many :posts, :include => :comments
- has_many :comments, :through => :posts
- end
- class Post
- belongs_to :user
- has_many :comments
- end
- class Comment
- belongs_to :post
- belongs_to :creator, :class_name => 'User', :foreign_key => 'creator_id'
- end
- class CommentsController
- def create
- # params[:comment] is { :text => 'Blah', :post_id => 1 }
- current_user.comments.create!(params[:comment])
- # render something
- end
- end
Add Comment
Please, Sign In to add comment