use the value from validates_each in validator

This commit is contained in:
Adam Meehan 2009-02-08 12:46:22 +11:00
parent a1ae5f9313
commit 7ef9078369
3 changed files with 3 additions and 4 deletions

View File

@ -55,7 +55,7 @@ module ValidatesTimeliness
configuration.delete(:allow_nil) configuration.delete(:allow_nil)
configuration.delete(:allow_blank) configuration.delete(:allow_blank)
validates_each(attr_names, configuration) do |record, attr_name, value| validates_each(attr_names, configuration) do |record, attr_name, value|
validator.call(record, attr_name) validator.call(record, attr_name, value)
end end
end end

View File

@ -32,8 +32,7 @@ module ValidatesTimeliness
validate_options(@configuration) validate_options(@configuration)
end end
def call(record, attr_name) def call(record, attr_name, value)
value = record.send(attr_name)
value = record.class.parse_date_time(value, type, false) if value.is_a?(String) value = record.class.parse_date_time(value, type, false) if value.is_a?(String)
raw_value = raw_value(record, attr_name) raw_value = raw_value(record, attr_name)

View File

@ -500,7 +500,7 @@ describe ValidatesTimeliness::Validator do
def validate_with(attr_name, value) def validate_with(attr_name, value)
person.send("#{attr_name}=", value) person.send("#{attr_name}=", value)
validator.call(person, attr_name) validator.call(person, attr_name, value)
end end
def should_have_error(attr_name, error) def should_have_error(attr_name, error)