title: Nonblocking data validation before saving
body: <p>i want to validate data before saving in my rails app.
  If data do not meet criteria of validation then was'nt save and the user wasn't warned.</p>
  
  <p>Actually i have this in the concerned model file : </p>
  
  <pre><code>class Product &lt; ActiveRecord::Base
      belongs_to :content
      before_validation :strip_whitespace  
      private
          def strip_whitespace
              self.label = self.label.strip
              self.price = self.price.strip
          end
  end
  </code></pre>
  
  <p>I have tried something like this in my other model :</p>
  
  <pre><code>class Content &lt; ActiveRecord::Base
      belongs_to :user
      has_many :products, :dependent =&gt; :destroy
      accepts_nested_attributes_for :products, :reject_if =&gt; :all_blank
  end
  </code></pre>
  
  <p><strong>[EDIT]</strong></p>
  
  <p>I finally change this line to :</p>
  
  <pre><code>class Content &lt; ActiveRecord::Base
      belongs_to :user
      has_many :products, :dependent =&gt; :destroy
      accepts_nested_attributes_for :products, :reject_if =&gt;  proc {|attributes| 
          attributes['label'].blank?
          attributes['price'].blank?
          attributes['img_src'].blank?
          attributes['link'].blank?
      }
  end
  </code></pre>
  
  <p>And it work !
  But there are another solution to list attributes with <strong>blank?</strong> condition ?</p>