In one of my models I have these lines :
belongs_to :user, :validate => true
…
validates_associated :user
When I remove the 2nd one, my tests run noticeably faster. Is the
above causing validations to be run twice ?
In one of my models I have these lines :
belongs_to :user, :validate => true
…
validates_associated :user
When I remove the 2nd one, my tests run noticeably faster. Is the
above causing validations to be run twice ?
And if it is a duplication, are there any differences, and which
method is best ?
Also, is there some reason why validates_associated does not throw an
exception on nil ?
That’s just the way it’s designed to work. If you want to make sure it’s
not
null, you’ll need to also use validates_presence_of or validates
:presence
=> true
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs