I’m trying to figure out on how to trigger the before_validation for only one specific column as you can see below.
class PartType < ActiveRecord::Base
before_validation :fix_quotation
protected
def fix_quotation
self[:quotation] = quotation_before_type_cast.tr(' $, ' , '.' ) if attribute_names().include?("quotation")
end
end
but the attribute_names seems not to be working in this case.
I have some other columns on this model and if I do any change on other columns this validation are trigging.
This validation is working fine with the “quotation” column but I don’t want that the validation trigger on modifying “title column for example.
NOTE: I’m using the gem called “on_the_spot” to edit column values “on the spot”
Here’s how your model should be defined: