how to override [] brackets in ruby?

后端 未结 3 1819
灰色年华
灰色年华 2020-12-17 20:19

I am writing an Ajax request form with Ruby on Rails using a collection_select tag that looks like this:

<%= collection_select(\"Jobs\", \"cl         


        
3条回答
  •  伪装坚强ぢ
    2020-12-17 21:02

    You need to use params[:Jobs][:clearance]

    params is a hash of all the request parameters. But params[:Jobs] is ALSO a hash of all :Jobs parameters. So calling params[:Jobs][:clearance] is calling the [] method on the params[:Jobs] object passing :clearance in as a parameter.

提交回复
热议问题