Multipe Combo box Query System


Anybody tell me, how i can implement multiple query system which is related hierarchically ?


  1. Year,
  2. Files in that selected year.

I think you will need to be a lot more specific about your
requirement. I, for one, have little idea what you mean. If you are
just talking about related tables (has_many, belongs_to etc) then have
a look at the Rails Guide on ActiveRecord Relationships.


Dear Collin,

Sorry for failing in explaining the problem. I wish to apply like

  1. collection_select (country)
  2. collection_select (state)
  3. collection_select (city)

I need to give the query system hierarchically.

(Eg. select India -> then it should populate states in India-> select state tamilnadu-> it should populate cities in tamilnadu-> select madras-> It should get all params values as params[:country], :params[:state], :params[city]->@list = Table.find(conditions…params[:country], :params[:state], :params[city]))

This is the exact problem I need. In tutorials, this kind of hierarchal collection_select options are not available… If clear tutorials available kindly tell me… With Advanced Thanks.

You should look into:

for info on how to use observe_field in combination with a select. I
just did a sursory review, and it looks like a decent solution


1. collection_select (country)
2. collection_select (state)
3. collection_select (city)


(Eg. select India -> then it should populate states in India-

You can add onchange to 1 and 2 above, eg.
   collect_select( ...,
remote_function(:url=>controllers_path, :method=>:get,
'country='+options[selectedIndex].value" ) )

where "controllers_path" is a path to an action that,

Or you could write some unobtrusive jQuery code to perform similarly.


Dear Jeff,

Thank you very much… Excellent.

Ryan Bates did an excellent screencast that does exactly just that:

Supposedly this plugin does the same thing

Haven't tried it personally, so can't vouch for it.