I am getting this error. ActiveRecord::AssociationTypeMismatch in Resources#create Focus expected, got String I have a select menu named resource[focus]. My focus (belongs_to :resources) table has a one-to-many relationship with the resources (has_one :focus) table (A resource will have only one focus but one focus will have many resources). I assume this error means that the focus is looking for a string (I am sending an integer, focus_id). What do I do? Thanks. Seth Buntin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060221/16a61887/attachment.html
Okay. I figured out that my relationship association was messed up (resources: belongs_to :focus and focus: has_many :resources) but I still get the same error. Seth Buntin Web Resources Coordinator Kentucky Academy of Technology Education Murray State University -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060221/24ade202/attachment-0001.html
Okay. I figured out that my relationship association was messed up (resources: belongs_to :focus and focus: has_many :resources) but I still get the same error. -- Posted via http://www.ruby-forum.com/.
Seth Buntin - KATE wrote:> Okay. I figured out that my relationship association was messed up > (resources: belongs_to :focus and focus: has_many :resources) but I > still get the same error.I decided to see what would happen if I used the console and here is what I found out. I start the console: # ruby script/console # resource = Resource.new() .... # resource.focus = 1 THEN I GET THE ERROR: Focus Expected, got Fixnum If I put resource.focus = ''1'' or "1" I get. Focus Expected, got String. What is it wanting? -- Posted via http://www.ruby-forum.com/.
On 21/02/06, Seth Buntin - KATE <seth.buntin@coe.murraystate.edu> wrote:> Seth Buntin - KATE wrote: > > Okay. I figured out that my relationship association was messed up > > (resources: belongs_to :focus and focus: has_many :resources) but I > > still get the same error. > > I decided to see what would happen if I used the console and here is > what I found out. > > I start the console: > > # ruby script/console > # resource = Resource.new() > .... > > # resource.focus = 1 > > THEN I GET THE ERROR: Focus Expected, got Fixnum > > If I put resource.focus = ''1'' or "1" I get. > > Focus Expected, got String. > > What is it wanting?It simply wants Focus :) Try: # resource.focus = Focus.new and this: # resource.focus_id = 1 Use resource[focus_id] in view. -- ?ukasz Piestrzeniewicz