[Rails] Re: Associations with value passing

2016-02-16 Thread Szabolcs Toth
Walter Davis wrote in post #1181415: >>@comment = Comment.new(comment_params) >>@comment.post_id = params[:id] >> >> But it doesn't work, what did I miss? Thank you! >> > > If you're sending this to the comments controller, then set the post_id > attribute in that form. id always refers to

[Rails] Associations with value passing

2016-02-15 Thread Szabolcs Toth
I have completely lost with this simple problem. I have two model, Post and Comment. I added the one-to_many associations. When I want to add a comment to a certain post I use this: <%= link_to 'Add comment', new_comment_path(id: post.id) %> In the comments_controller.rb I have def create