Damir Nurgaliev Damir Nurgaliev - 3 months ago 48
Ruby Question

Setting hidden field in edit form

I'm creating posts to blogs. Here's code to create post

= simple_form_for post do |f|
= f.error_notification
= f.input :title
= f.input :content
= f.hidden_field :blog_id, value: params[:blog_id]
= f.button :submit

Creating works fine, but when I tried to edit created post with same form a got an error.
Console log:

"post"=>{"title"=>"xzcascdasd", "content"=>"", "blog_id"=>""},
"commit"=>"Update Post", "id"=>"2"}

Should I set here blog_id? It doesnt work without blog_id too. Any ideas?

= f.hidden_field :blog_id, value: params[:blog_id]

is params[:blog_id] existing on this page ??