Topic: select menu page jump and secondary menu propagation

This is two similiar questions, all deriving from my inability to wrap my brain around the intriacies of select_tag, observe_field and AJAX.

One. I want a drop menu that is propagated from the database, ala:

select(:state_id,:name_full,@states.map {|p| p.name_full})

which pushes the state.name_full as an id to an action called local, bringing us to a new page. How should this be done, the rails way?

Second. In a similiar vein, in a seperate form, I want a state selection to propagate a second select drop down, both database driven. I know about observe_field, I just don't know how to implement it.

If it helps, here's my relevant schema.

State table (has_many :locations) = state_id, name_full
Location table (has_one :state) = city_name, state_id

Any help would be greatly appreciated and cool down my cooking brain.

Re: select menu page jump and secondary menu propagation

For starters your schema is not very Rails-ish, this is much better:

states table (has_many :locations) = name_full # id field is automatically set by Rails
locations table (has_one :state) = city_name, state_id

As for your other issues:

1. Use collection_select helper

<%= collection_select :state_id, @states, :id, :name, {:prompt => 'Choose ...'} %>

Then you can use AJAX to redirect. See this thread: http://railsforum.com/viewtopic.php?id=10448

2. Use :onchange attribute

<%= collection_select :state_id, @states, :id, :name, {:prompt => 'Choose ...'}, {:onchange => "someJSfunction();"} %>