POST 数据拆分时的单独表单参数
我正在尝试从表单单独访问日期变量到其他变量。该表单是一个 formattastic 插件表单。我面临的问题是日期是由三部分组成的下拉列表,简单地执行 params[:friend][:born_on] 似乎并没有达到目的,因为它返回 NULL。
这是我的参数输出;
参数:{"commit"=>"创建", "action"=>"创建", "authenticity_token"=>"6+PyuqUNQySe29iEF69PIFvv6DOie5bp4jZAcRva85c=", "controller"=>"朋友", "朋友"=>{"born_on(1i)"=>"1973", "born_on(2i)"=>"3", "born_on(3i)"=>"5", "is_female"=> ;"false", "last_name"=>"史密斯", "first_name"=>"John"}}
我想使用该变量来设置另一个方法; event.happening_on
如有任何帮助,我们将不胜感激 - 谢谢!
I'm trying to access a date variable from a form individually to the other variables. The form is a formtastic plugin form. The issue I am facing is that the date is a three-part dropdown and simply doing params[:friend][:born_on] doesn't seem to be doing the trick as it returns NULL.
Here is my parameters output;
Parameters: {"commit"=>"Create", "action"=>"create", "authenticity_token"=>"6+PyuqUNQySe29iEF69PIFvv6DOie5bp4jZAcRva85c=", "controller"=>"friends", "friend"=>{"born_on(1i)"=>"1973", "born_on(2i)"=>"3", "born_on(3i)"=>"5", "is_female"=>"false", "last_name"=>"Smith", "first_name"=>"John"}}
I want to use the variable to set another method; event.happening_on
Any help is appreciated- thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
params[:friend][:born_on] 不返回任何内容的原因是因为那不是参数的名称。
您要查找的值似乎是以下之一:
params[:friend]["born_on(1i)"]
、params[:friend]["born_on(2i)" ]
或params[:friend]["born_on(3i)"]
。分别对应于年、月、日。The reason params[:friend][:born_on] is not returning anything is because that's not the name of the parameter.
It looks like the values you're looking for is one of:
params[:friend]["born_on(1i)"]
,params[:friend]["born_on(2i)"]
, orparams[:friend]["born_on(3i)"]
. Which corresponds to what looks like, year, month and day respectively.