title: How to "accept" nested class object instances by running a custom method before to store those?
body: <p>I am using Ruby on Rails 3.1.0 and I would like to run a <code>:reject_if</code> method (<em>as</em> described in the <a href="http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html" rel="nofollow">official documentation</a> related to the <code>accepts_nested_attributes_for</code> method in the "One-to-many" association section) on class object instances "<em>at all</em>" (that is, to run the <code>:reject_if</code> method <em>not</em> on attributes - as made in the linked documentation - but on records that should be "subsequently" stored in the database). In few words, I would like to reject\filter some nested model\class object instances that should be stored in the database by running a custom method on those instances.</p>
  
  <p>For example, if I have the following:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    has_one :article,
  
    accepts_nested_attributes_for :article
  end
  </code></pre>
  
  <p>I would like to make something like this (the following code does not work):</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    has_one :article,
  
    # Note: by using 'article' in the block I (would like to) refer to class
    # object instances
    accepts_nested_attributes_for :article, :reject_if =&gt; { |article| article.can_be_created? }
  end
  
  class Article &lt; ActiveRecord::Base
    def can_be_created?
      true if user.has_authorization?
    end
  end
  </code></pre>
  
  <p><strong>Is it possible? If so, how can I make that?</strong></p>