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 the text field. However, I want these values to map to the same underlying attribute. Any suggestions?
on 2006-01-24 05:25
on 2006-01-24 06:29
class MyClass def before_save if MyClass.select_box_value == 'other' and not params[:text_field_other].empty? MyClass.select_box_value = params[:other_selection] end end end This may not be totally accurate, but it'll get you pointed in the right direction. 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 class. Cheers, Bob Silva
on 2006-01-25 22:51
Thanks Bob! I'll give that a try and see what I can do. Sometimes I just get 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.