在params内访问params?

时间:2013-05-26 00:41:03

标签: ruby-on-rails

表单上的提交发送params[:model],里面有其他哈希,例如:attribute_1=>value_1

例如,服务器日志:

Started POST "/tests/1/create_answer" for 127.0.0.1 at 2013-05-26 04:36:09 +0400
Processing by TestsController#create_answer as JS
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"sFZIbaxVSnf1auEbsGMdVVl7dg0OWXKnFA0pl1aXA9o=", "answer"=>{"user_answer"=>"ssss", "position"=>"96", "key_id"=>"2"}, "commit"=>"", "id"=>"1"}

有没有办法在控制器中访问任何这些属性,某种:

@key=Key.find(params[:answer][:key_id])

试过这个,返回nil。

0 个答案:

没有答案