Sending data in my form hidden field

白昼怎懂夜的黑 提交于 2019-12-06 15:38:47

Ok, shot in the dark here:

Try

<%= f.hidden_field 'event_id', :value => params[:event_id] %>

Edit - Why it worked:

The hidden_field method has the following signature: hidden_field(object_name, method, options = {}) See the docs about hidden_field

You have passed the value 16 as a method to be called by hidden_field, and that would not work.

The third argument of hidden_field is a options hash. Setting the "value" field of that hash will set the value of the input tag generated by the helper, and thus effectively setting '16' as the value of that form field. :)

Best regards

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!