title: What is the order of ActiveRecord callbacks and validations?
body: <p>I was wondering in what order are callbacks and validations called when an ActiveRecord object is created.</p>
  
  <p>Let’s say I have some custom validations &amp; callbacks like the following:</p>
  
  <pre><code>validates :reference_code, :if =&gt; :reference_code, :on =&gt; :create
  before_create :assign_reference
  </code></pre>
  
  <p>which one will run first? The callback needs to happen first or else the validation may fail.</p>