我正在使用Ruby on Rails编写一个Ajax请求表单,使用如下所示的collection_select标记:
<%= collection_select("Jobs", "clearance", @allClearances, "clearance", "clearance", {:prompt => "Select a Clearance"} )%>
Run Code Online (Sandbox Code Playgroud)
然后,Ruby使用id = "Jobs_clearance"和构建HTML选择标记name = "Jobs[clearance]"
我想将参数发送到我的控制器,如下所示:
class JobsController < ApplicationController
def foo
@clearance = params[:Jobs[clearance]]
end
Run Code Online (Sandbox Code Playgroud)
不幸的是,Ruby只读取":Jobs"符号而不是":Jobs[clearance]"
有没有办法逃脱它[]的?反斜杠不起作用.