--- !ruby/object:RI::MethodDescription 
aliases: []

block_params: 
comment: 
- !ruby/struct:SM::Flow::P 
  body: Validates whether the associated object or objects are all valid themselves. Works with any kind of association.
- !ruby/struct:SM::Flow::VERB 
  body: "  class Book &lt; ActiveRecord::Base\n    has_many :pages\n    belongs_to :library\n\n    validates_associated :pages, :library\n  end\n"
- !ruby/struct:SM::Flow::P 
  body: "Warning: If, after the above definition, you then wrote:"
- !ruby/struct:SM::Flow::VERB 
  body: "  class Page &lt; ActiveRecord::Base\n    belongs_to :book\n\n    validates_associated :book\n  end\n"
- !ruby/struct:SM::Flow::P 
  body: ...this would specify a circular dependency and cause infinite recursion.
- !ruby/struct:SM::Flow::P 
  body: "NOTE: This validation will not fail if the association hasn't been assigned. If you want to ensure that the association is both present and guaranteed to be valid, you also need to use validates_presence_of."
- !ruby/struct:SM::Flow::P 
  body: "Configuration options:"
- !ruby/object:SM::Flow::LIST 
  contents: 
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: "<tt>message</tt> - A custom error message (default is: &quot;is invalid&quot;)"
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: <tt>on</tt> Specifies when this validation is active (default is :save, other options :create, :update)
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: <tt>if</tt> - Specifies a method, proc or string to call to determine if the validation should occur (e.g. :if =&gt; :allow_validation, or :if =&gt; Proc.new { |user| user.signup_step &gt; 2 }). The method, proc or string should return or evaluate to a true or false value.
  - !ruby/struct:SM::Flow::LI 
    label: "*"
    body: <tt>unless</tt> - Specifies a method, proc or string to call to determine if the validation should not occur (e.g. :unless =&gt; :skip_validation, or :unless =&gt; Proc.new { |user| user.signup_step &lt;= 2 }). The method, proc or string should return or evaluate to a true or false value.
  type: :BULLET
full_name: ActiveRecord::Validations::ClassMethods#validates_associated
is_singleton: false
name: validates_associated
params: (*attr_names)
visibility: public
