I want to use a value entered in by a user in an object's form to look
up another value in a reference table and assign that value to the
corresponding attribute in the object. How do I do that?
Right now I have in my controller create method:
if @number = Work.find_by_sql( "SELECT inv FROM
samples_development.works WHERE worknbr REGEXP '" +
@sample['work_number'] + "';" )
@sample.inv = @number
end
But it assigns something odd to the number attribute that looks like
this:
!ruby/object:Work attributes: inv: INV 1986/MR 690/2201
attributes_cache: {} -
Should I be doing this in the model instead?
--
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.