I am a newbie of ruby on rails. And I have met a problem with model
association.
I have 2 tables here, one is "item" the other is "brand", when I
create one new item, I want to select one brand from the list.
Here are the models:
class Brand < ActiveRecord::Base
has_many :items
end
class Item < ActiveRecord::Base
belongs_to :brand
end
for item/new view
<% form_for(@item) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :Brand %><br />
<%= f.collection_select(:brand, Brand.find(:all), :id, :name,
{:prompt => "please select one brand"}) %>
</p>
...
I can get the list successfully when create the new item, but when I
press the "create" button, I've got the "Brand(#57323960) expected,
got String(#21132310)" AssociationTypeMismatch error
I am not sure why I got the AssociationTypeMismatch error, and how can
I handle this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---