Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Pass validated record to the custom message proc

#6452

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

Reported by Ɓukasz Bandzarewicz · February 18th, 2011 @ 05:55 PM

State: new
Milestone: none
Assigned to: nobody
Importance: none

Activity

No comments yet.