Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class OnlyOnceValidator < ActiveModel::EachValidator
- def validate_each(record, attribute, value)
- if record.send( "#{attribute}_changed?" ) && record.send( "#{attribute}_change" )[0]
- record.errors[attribute] << (options[:message] || "has set already")
- end
- end
- end
Add Comment
Please, Sign In to add comment