I've got a model, Photo, that has two options, is_photo or is_art, each with their own separate fields.
But, when one option is chosen I want the other option's fields to be reset into blank strings.
This is what I have:
photo.rb
before_save :reset_photo_options
before_save :reset_art_options
def reset_photo_options
if self.is_art == 1
self.resolution = ""
self.camera = ""
end
end
def reset_art_options
if self.is_photo == 1
self.tool = ""
self.medium = ""
end
end
However, if I fill out the is_photo fields and then change to is_art and fill those out all of the fields are saved.
How can I successfully reset the other option's fields?
is_artandis_photoare actual DB fields I'd revisit that choice (maybe even STI, which is fine for simple usecases).