Form.select problem

Dear all,

I tried to implement the code for 2 select boxes that are dependent on
each other. One has a list of countries, and one a list of states.
Now, this code works:

<%= select :state, :id, Country.find(@country.id).states.map {|x| [x.name, x.id]} %>
<%= select :country, :id, Country.find(:all, :order => 'name ASC').map {|x| [x.name, x.id]} %>

However, I want to place this inside my form_for. This code does not
work:

<% form_for (:trail, :url => { :action => “update”, :id =>
@trail }, :html => { :multipart => true }) do |form| %>

<%= select :state, :id, Country.find(@country.id).states.map {|x| [x.name, x.id]} %>
<%= select :country, :id, Country.find(:all, :order => 'name ASC').map {|x| [x.name, x.id]} %> <%= submit_tag "Save" %> <% end %>

The view crashes with this error message:

ActionView::TemplateError (undefined method `merge’ for #<Array:
0x33d1b68>) on line #110 of app/views/trail_editor/edit.rhtml:
107:
108:


109: Country:
110: <%= form.select :country, :id, Country.find(:all,
:order
=> ‘name ASC’).map {|x| [x.name, x.id]} %>
111:
112:
113: Directions
to Trailhead:

Any help would be greatly appreciated.

Thank you,

Nick wrote:

The view crashes with this error message:

ActionView::TemplateError (undefined method `merge’ for #<Array:
0x33d1b68>) on line #110 of app/views/trail_editor/edit.rhtml:
107:
108:


109: Country:
110: <%= form.select :country, :id, Country.find(:all, :order
=> ‘name ASC’).map {|x| [x.name, x.id]} %>

You want: <%= form.select :country_id, …


We develop, watch us RoR, in numbers too big to ignore.

Nick,
What I can’t figure out is that you seem to try to select the STATE
first and then select the country. This seems backwards?
Could you digest a bit of what’s going on here?
And thank you Mark for filling in the error.
Thank you,
Kathleen