ActiveRecord::Base.class_eval do

  def self.validates_is_exact(*attr_names)
    options = attr_names.extract_options!
    validates_each(*(attr_names << options)) do |record, attr_name, 
value|
      if record.send( options[:compare_field] ) != value
        record.errors.add(attr_name, options[:message])
      end
    end
    true
  end

end

=========

Read the post above Marnen, but for thoroughness, I'm supplying the code 
I have in my initializers folder for validators.rb.  This way you can 
see what I'm doing precisely.

Take care mate.
-- 
Posted via http://www.ruby-forum.com/.
-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to