I'm using Ruby on Rails and I'm trying to access a filterrific scope variable from a 'select' drop down in the view for use in the controller.
Basically, my code looks like this.
<%= form_for_filterrific @filter do |c| %>
<%= c.select(:departments, @filter.select_options[:docs], {}, {style: "width: 140px;"} ) %>
<% end %>
Is there a way for me to get the currently selected doc
option from the drop down and send it to a controller?
After form was submitted you can get selected option in controller from params
, something like:
params[:filterrific][:departments]
In any case try inspect params
in controller to investigate:
puts params.inspect
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.