This is basic HTML stuff, but if you have a form input like a dropdown (select), the value you choose in that element is only sent to the server if it is inside a form element, and you submit that form in some way to the server. On the server, you need to permit that attribute in strong parameters, so it won't be filtered out, and then use that in your controller method to act as your filter.
Whether you submit the form via JavaScript or add a submit button and have the user press it makes no difference to the server.
If you're on an index page, say
www.example.com/pages, then you can code the form like this:
<%= form.for url: '/pages', method: :get do |f| %>
<%= f.collection_select :filter, %w[both true false], :to_s, :to_s, onchange: "this.form.trigger('submit')", prompt: true %>
<%- end -%>
That's going to submit to your controller in the index method, where I presume you will do the rest.
Walter
>
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to
rubyonra...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/d9fee589-42ab-4eb6-af26-70bbd25ba26c%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.