提交 d33f814d 编写于 作者: D David Heinemeier Hansson

Changed the Proc for a string to avoid repetition problems

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@96 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 a65f791f
......@@ -75,11 +75,9 @@ module ClassMethods
def validate_confirmation(*attr_names)
for attr_name in attr_names
attr_accessor "#{attr_name}_confirmation"
class_eval <<-EOC
validate_on_create(Proc.new { |record|
record.errors.add("#{attr_name}", "doesn't match confirmation") unless record.#{attr_name} == record.#{attr_name}_confirmation
})
EOC
class_eval <<-EOM
validate_on_create %{errors.add('#{attr_name}', "doesn't match confirmation") unless #{attr_name} == #{attr_name}_confirmation}
EOM
end
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册