Guest User

Untitled

a guest
Dec 12th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. class OnlyOnceValidator < ActiveModel::EachValidator
  2. def validate_each(record, attribute, value)
  3. if record.send( "#{attribute}_changed?" ) && record.send( "#{attribute}_change" )[0]
  4. record.errors[attribute] << (options[:message] || "has set already")
  5. end
  6. end
  7. end
Add Comment
Please, Sign In to add comment