title: ActiveRecord - validation :allow_blank is always active even if it has :unless
body: <p>I have this model </p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    attr_accessible :type, :school_name, :school_grade
  
    validates :type, :inclusion =&gt;{:in =&gt;['1','2']}, :allow_blank =&gt; true
    validates :school_name,  :presence =&gt;{:if =&gt; :student?}
    validates :school_grade, :numericality =&gt;{:only_integer =&gt;true}, :allow_blank =&gt; {:unless =&gt; :student?}
  
    def student?
      type.to_s == '1'
    end
  end
  </code></pre>
  
  <p>I tried following patterns.</p>
  
  <pre><code>User.create(:type =&gt;'2', :school_name =&gt;nil, :school_grade =&gt;nil)
  </code></pre>
  
  <p>=> OK. No error occurred.</p>
  
  <pre><code>User.create(:type =&gt;'1', :school_name =&gt;nil, :school_grade =&gt;1)
  </code></pre>
  
  <p>=> OK. ActiveRecord::RecordInvalid error "school_name is empty" occurred.</p>
  
  <pre><code>User.create(:type =&gt;'1', :school_name =&gt;'foo', :school_grade =&gt;'string is not a number')
  </code></pre>
  
  <p>=> OK. Validetion error "school_grade is not a number" occurred.</p>
  
  <pre><code>User.create(:type =&gt;'1', :school_name =&gt;'foo', :school_grade =&gt;nil)
  </code></pre>
  
  <p>=> NG. I expect "school_grade is not a number" error, but no error occurred.</p>
  
  <p>I tried this pattern also, but got same result.</p>
  
  <pre><code>  validates :school_grade, :numericality =&gt;{:only_integer =&gt;true}, :allow_blank =&gt; {:if =&gt; :not_student?}
  
    def not_student?
      type.to_s != '1'
    end
  </code></pre>
  
  <p>I guess validation :allow_blank is always active, but why? And how to fix it?</p>
  
  <p>Thank you.</p>