This project is archived and is in readonly mode.

#6452 new
Łukasz Bandzarewicz

Pass validated record to the custom message proc

Reported by Łukasz Bandzarewicz | February 18th, 2011 @ 05:55 PM

I've added a small improvement to the validation errors processing.
It allows to pass the validated record to the proc for generating a custom error message. For instance we could use it this way:

class Subscription < ActiveRecord::Base

  validates :city, :presence => true
  validates_uniqueness_of :email, :scope => [:city_id], 
    :message => proc { |s| "You're already subscribed to #{city.name}" }

end

No comments found

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages