Hi all
I guess this is quite a newbie question, but I’m just stuck here and
don’t know why.
<%= form.collection_select :origin_country, Country.find(:all), :id,
:name %>
gives me a select list with name=“member[origin_country]”. When
submitting the form the following error is shown:
Country expected, got String
When I try
<%= form.collection_select :origin_country_id, Country.find(:all), :id,
:name %>
I get the error
undefined method `origin_country_id’ for #Member:0x23f52e8
So I try it with
<%= form.select :origin_country, Country.find(:all).map{|obj| [obj.name,
obj.id]} %>
but again the same “Country expected, got String” error.
As far as I know Rails expects a select list with a name
“member[origin_country_id]” or something like that?
My models look like that:
class Member < ActiveRecord::Base
belongs_to :origin_country,
:class_name => ‘Country’
end
class Country < ActiveRecord::Base
has_many :originating_members,
:class_name => ‘Member’
end
And the foreign key column in the members table is called “country_id”.
So where’s the mistake? Thanks a lot for help.
Joshua