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.

2.1.2 changes ActiveRecord validation sequence for associations

#1298

Person has one ContactInfo.

class Person < ActiveRecord::Base has_one :contact_info, :as => :contactable, :dependent => :destroy end

On rails 2.1.0 ContactInfo validation is done before Person validation. So, I can catch the errors in the contact info in Person after_validation call back. This is necessary since I only display a single form to the user.

When I migrate the same code to 2.1.2, it looks like ContactInfo validation is done after Person validation. So, I can not catch the contact info error in Person after_validation call back.

To me, this looks like a problem that would affect many applications since you can not catch dependent association errors.

Reported by Ahmet Dogramaci · October 30th, 2008 @ 12:14 PM

State: invalid
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Pratik
    Pratik
    • State changed from new to invalid

    That's expected behaviour. You could also play with :validate => true/false to match your needs.

    Thanks

    March 12th, 2009 @ 04:08 PM