select_tag坐在用户参数之外?

时间:2013-12-11 13:55:55

标签: ruby-on-rails

下午全部,

一直试图弄清楚这是从哪里来的但是无法理解为什么我会得到以下内容,这是我的select_tag。

<%= select_tag :area_of_focus, options_for_select(User::LANGUAGES), {multiple: true, include_blank: false} %>

这是常数:

 LANGUAGES = ["Rails", "Ruby", "Javascript", "C#", "HTML", "CSS", "SQL" ]

当我在更新时运行提交时,我在area_of_focus上得到以下验证错误。首先,这是来自rails控制台日志,

"area_of_focus"=>["Javascript"]

这是来自我页面上的调试:

area_of_focus: ! '["Javascript"]'

更新:刚刚注意到我的params列在下面,:area_of_focus位于用户哈希之外:

  Parameters: {"utf8"=>"✓", "authenticity_token"=>"ZAAObfDDIUumIJV2cQjkZSkaUY6RsHbdFY1MEd28hvI=", "user"=>{"company_name"=>"kdkdsh", "street"=>"ksakjakjs", "city"=>"kjsdkjskds", "state"=>"kdjsksksj", "postcode"=>"ksdjkssk", "employer_desc"=>"kdjskksdhdsjs", "number_of_employees"=>"100", "email"=>"shaun@shaun1.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "current_password"=>"[FILTERED]"}, "area_of_focus"=>["Ruby", "Javascript"], "commit"=>"Update"}

我在这里做错了什么?

1 个答案:

答案 0 :(得分:2)

尝试:<%= form.select :area__of_focus, ....