Topic: How to pass the UI control values as the parameters to the Controller

I met a problem of parameter passing in Rails.

I have an object named 'account' and another object named 'locale'. There is a one-to-many relationship between them. One locale can be mapped with multiple accounts.

On accounts/index.html.erb, I have a dropdown which will list all the available locales. And I have a link below.

In expectation, when I clicks this link, the index method of account controller will be called and the value of selected locale id will be passed. And the index method will retrieve all the accounts belonging to that locale.

What blocks me is I have no idea how to pass that selected value of dropdown to the controller.

I only know the basic way of passing a parameter is:

<%= link_to 'Refresh', {:action => 'index', :fromvar => 'refresh', :selected_locale_id => '1'}.

And from controller, we can get it by:

params[:selected_locale_id]

But it is the case of a fixed value. How to deal with a dynamic UI control value as my case?

Does link_to support some javascript to be embedded?

My rails version is 3.2.13.

Any one has idea on this?

Thanks~

Re: How to pass the UI control values as the parameters to the Controller

Current Rails style favors RESTful routes whenever possible, so base your application on resources. If not, you will have to configure your routes so that to be able to call corresponding actions/methods in controllers.
To check your available routes, just navigate to you app in the terminal and run:

rake routes

For more details on link_to method, see Rails API and search link_to method. See Rails Guides for Routes as well.