Ok i have a model named Tire and I cant update the name field on some reserved names
class Tire < ActiveRecord::Base
RESERVED_TIRES = ['Michelin', 'Good Year', 'Firestone']
before_update :reserved_tires
def reserved_tires
if RESERVED_TIRES.include?(self.name)
self.errors.add(:base, "Cant be changed")
false
end
end
end
And i need to not allow the user to update any field is the current name is in the reserved words...this works for all fields other then when the user updates name.
For example is the user updates to "Michelinnnn" then it allows the update because self.name is "Michelinnnn" rather then 'Michelin' which is saved in the DB. Any ideas on how to address this