Hello Chris:
There's also an :if option for the validates_associated class method:
":if - Specifies a method, proc or string to call to determine if the
validation should occur (e.g. :if => :allow_validation, or :if =>
Proc.new { |user| user.signup_step > 2 }). The method, proc or string
should return or evaluate to a true or false value."
http://apidock.com/rails/ActiveModel/Validations/ClassMethods/validates_associated
Cheers,
Nicholas
On Jul 29, 4:09 pm, Chris Habgood <[email protected]> wrote:
> Ya, now that you said a flag would be good. I was initially referring to
> the main Site model initiating the validation for the equipment but a flag
> in the equipment model would probably be an easier solution.
>
>
>
> On Wed, Jul 29, 2009 at 2:53 PM, Colin Law <[email protected]> wrote:
>
> > 2009/7/29 Chris Habgood <[email protected]>:
> > > I have the main form "Site", has many :equipments.
> > > In the Site form I add equipment to the form dynamically to associate it
> > to
> > > the site.
> > > I do not necessarily need to validate the equipment fields on the form
> > > submission unless a checkbox is checked on the "Site" form stating
> > > everything is good.
> > > Basically I only need to validate the equipment under specific case on
> > the
> > > site model.
>
> > So, is this it? A user has entered data for an Equipment record onto
> > the form and submitted it, you have some validations defined but you
> > only want to run them if the associated site record (in the db) has a
> > particular flag set? If the flag in the db is not set then you want
> > to save the Equipment record without validating?
>
> > Colin
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---