sreid
2011-Aug-25 17:06 UTC
activerecord model belongs_to and validates_associated duplicate validation
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 ? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
sreid
2011-Aug-25 17:11 UTC
Re: activerecord model belongs_to and validates_associated duplicate validation
And if it is a duplication, are there any differences, and which method is best ? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
sreid
2011-Aug-25 17:33 UTC
Re: activerecord model belongs_to and validates_associated duplicate validation
Also, is there some reason why validates_associated does not throw an exception on nil ? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Tim Shaffer
2011-Aug-25 17:53 UTC
Re: activerecord model belongs_to and validates_associated duplicate validation
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 On Thursday, August 25, 2011 1:33:07 PM UTC-4, sreid wrote:> > Also, is there some reason why validates_associated does not throw an > exception on nil ? >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/QC0xq9zfciAJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.