If you just want to hide the field use:
<%= f.hidden_field :post_id, value: params[:id] %>
See
-
http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-hidden_field
On Tuesday, February 16, 2016 at 4:48:17 AM UTC-8, Ruby-Forum.com User
wrote:
>
> Walter Davis wrote in
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
2 matches
Mail list logo