class ActiveModel::Validations::RolesValidator
Public Class Methods
new(options)
click to toggle source
Calls superclass method
# File lib/active_model/validations/roles_validator.rb, line 10 def initialize(options) @roles = options[:roles] super end
Public Instance Methods
validate_each(record, attribute, value)
click to toggle source
# File lib/active_model/validations/roles_validator.rb, line 14 def validate_each(record, attribute, value) unless value.split("_").all? {|x| @roles.include?(x) } record.errors[attribute] << (options[:message] || "contains an invalid role") end end