[英]f.hidden_field in rails 3.2
I am trying to insert a user id from devise into another table which collects contact details and company name and so on and i am using - 我试图从设计插入用户ID到另一个表收集联系人详细信息和公司名称等等我正在使用 -
<%= f.hidden_field :user_id, current_user.id %>
and all i seem to get back is an error on the page when i load it up - 当我加载它时,我似乎回来的是页面上的错误 -
undefined method `merge' for 1:Fixnum
Extracted source (around line #46): 提取的来源(第46行):
am i missing something, do I have to put anything in the controller so i can access the current_user information? 我错过了什么,我是否必须在控制器中放置任何东西,以便我可以访问current_user信息?
Any help with this would be appreciated. 任何帮助都将不胜感激。
Robbie 罗比
You can use it like 你可以像使用它一样
<%= f.hidden_field :user_id, :value => current_user.id %>
or 要么
<%= hidden_field_tag "user_id",nil,:value => current_user.id %>
Try it.. 试试吧..
你也可以这样做。
<%= hidden_field_tag('some_object[user_id]', current_user.id)%>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.