Forum: Ruby on Rails Map select value or other to same attribute

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
jason cartwright (Guest)
on 2006-01-24 06:25
(Received via mailing list)
I want to map a select control and a text field to a single attribute,
where the
end user can either select an option, or select "other" and then fill in
text field. However, I want these values to map to the same underlying

Any suggestions?
Bob S. (Guest)
on 2006-01-24 07:29
(Received via mailing list)
class MyClass

def before_save
  if MyClass.select_box_value == 'other' and not
    MyClass.select_box_value = params[:other_selection]


This may not be totally accurate, but it'll get you pointed in the right

NOTE: The text field will need to be output using text_field_tag or
hard-coded on the page. IT DOES NOT represent part of your ActiveRecord


Bob S.
Jason C. (Guest)
on 2006-01-25 23:51
(Received via mailing list)
Thanks Bob! I'll give that a try and see what I can do. Sometimes I just
lazy, or I want to understand "the rails way", and like to toss these
issues out
to the community. Thanks for the
suggestion and I'll get back with my success or questions shortly.
This topic is locked and can not be replied to.