Map select value or other to same attribute

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?

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 S.

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs