AckZ
2008-Mar-11 22:49 UTC
add_multiple_associated_save_callbacks and validates_associated conflict?
Perhaps I''m misunderstanding what''s happening here, but
I''m having a
problem with not being able to disable the validation of an associated
collection if that collection contains a new record. Example...
class Person < ActiveRecord::Base
has_many :email_addresses
validates_associated :email_addresses, :if => Proc.new { false }
end
p = Person.new
p.email_addresses.build
p.save (will return false and give you a validation error on
email_addresses)
There''s a validation set up by add_multiple_associated_save_callbacks
in ActiveRecord::Associations::ClassMethods that sends
''valid?'' to any
new records in the collection, which pretty much negates the
usefulness of having validates_associated accept if and unless
parameters in the first place.
If anyone else has run into this, I''d like to see whatever workarounds
you''ve come up with.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2008-Mar-12 05:00 UTC
Re: add_multiple_associated_save_callbacks and validates_associated conflict?
AckZ wrote:> There''s a validation set up by add_multiple_associated_save_callbacks > in ActiveRecord::Associations::ClassMethods that sends ''valid?'' to any > new records in the collection, which pretty much negates the > usefulness of having validates_associated accept if and unless > parameters in the first place. > > If anyone else has run into this, I''d like to see whatever workarounds > you''ve come up with.http://groups.google.com/group/rubyonrails-talk/msg/553ac81685757842 -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---