Hi there Jose,

My first step would be to see if the problem still exists in the latest
2.3?  Ie. 2.3.18


On Mon, Apr 29, 2013 at 6:30 PM, jaambros <[email protected]> wrote:

> Devin, I already had tried
> has_many :phrases, :validate=>false
> and saw no difference
>
> On Apr 29, 5:12 pm, Devin Wadsworth <[email protected]> wrote:
> > I don't have time to test it right now, but I think has_many :phrases,
> > validate: false might be what you're looking for.
> >
> >
> >
> >
> >
> >
> >
> > On Monday, April 29, 2013 1:19:31 PM UTC-7, jaambros wrote:
> >
> > > Hi all, I've followed your list for sometime now and found always it
> > > to be a great resource. I ask your help on this one after searching
> > > for a solution all around to no avail.
> > > I have an application where I used anaf in a model with children;
> > > however as the number of children grew I noticed it was slowing up
> > > quite a bit. After some analysis I found that when updating values for
> > > one child anaf was doing validations on ALL chldren, which by then was
> > > numbering in the thousands.
> >
> > > To illustrate my point I created this  example:
> >
> > > class Language < ActiveRecord::Base
> > >   has_many :phrases
> > >   accepts_nested_attributes_for :phrases
> > > end
> >
> > > class Phrase < ActiveRecord::Base
> > >   validates_presence_of :value
> > >   belongs_to :language
> > >   def before_validation
> > >     print "\nValidating: #{self.value}\n"
> > >   end
> > > end
> >
> > > $ script/console
> > > Loading development environment (Rails 2.3.5)
> > > >> lang = Language.first
> > > => #<Language id: 1, name: "Italiano">
> > > >> lang.phrases
> > > => [#<Phrase id: 7, value: "Buona notte", language_id: 1>,
> > > #<Phrase id: 10, value: "Ciao", language_id: 1>,
> > > #<Phrase id: 11, value: "Prego", language_id: 1>]
> >
> > > >> lang.phrases_attributes = [{:id => "7", :value => "Buon giorno"}]
> > > => [{:value=>"Buon giorno", :id=>"7"}]
> > > >> lang.save
> >
> > > Validating: Buon giorno
> >
> > > Validating: Ciao
> >
> > > Validating: Prego
> >
> > > => true
> >
> > > I expected in this example to see validation only on only one phrase
> > > {id=>7}, but you can see it did it for all three.
> > > I don't think this is expected behavior, right?
> > > if so, can you help me find what I I'm missing?
> > > After looking up at the code for anaf I suspect the issue may be in
> > > autosave, but after a week trying to solve this I'm stumped.
> > > can you help me?
> >
> > > Thanks in advance, Jose
>
> --
> --
> SD Ruby mailing list
> [email protected]
> http://groups.google.com/group/sdruby
> ---
> You received this message because you are subscribed to the Google Groups
> "SD Ruby" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby
--- 
You received this message because you are subscribed to the Google Groups "SD 
Ruby" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to