mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
class Person < ActiveRecord::Base
include MyValidators
validates :name, :presence => true, :uniqueness => true, :length => { :maximum => 100 }
validates :email, :presence => true, :email => true
end
[#3058 status:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
15 lines
228 B
Ruby
15 lines
228 B
Ruby
class CustomReader
|
|
include ActiveModel::Validations
|
|
|
|
def initialize(data = {})
|
|
@data = data
|
|
end
|
|
|
|
def []=(key, value)
|
|
@data[key] = value
|
|
end
|
|
|
|
def read_attribute_for_validation(key)
|
|
@data[key]
|
|
end
|
|
end |