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
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
2 matches
Mail list logo