The current controller code I'm using to create a comment on a Post object is this:
commentable = @post
comment = commentable.comments.create
# comment.title = params[:title] #Title not needed
comment.comment = params[:comment][:comment]
comment.user = current_user
gon.post_id = @post.id #for javascript
if comment.save
....
This is also how it's recommended on the docs.
Is there a way to do this by passing the params into the .create function, like
(user = current_user ....)
This avoid making 2 calls to the db on a create, thus upping performance.
Additionally, if you're using the public_activity gem it makes things easier too. because it adds a Created and Updated activity on my database every time I write a comment.
Thnaks
more simpler approach to include commentable model in your rails app..Railscasts for adding commentable