title: raise ActiveRecord::RecordNotFound (or any 404 status) for invalid date
body: <p>In my controller controller, I have use <code>Date.new</code> to create a date object to be passed in my ActiveRecord.</p>
  
  <pre><code>end_range = Date.new(params[:year].to_i, params[:month].to_i, params[:day].to_i).end_of_day.to_formatted_s(:db)
  </code></pre>
  
  <p>The problem with this above is that if a user tried to change the parameters in the URL manually, such as entering <code>40</code> for the day param, the <code>Date.new</code> fails (as expected). However, I would rather not have a 500 error if a user typed in something like that, but instead a 404 error (because you will never actually be able a record with a day of <code>40</code>).</p>
  
  <p>I tried various conditionals (<code>if</code> and <code>unless</code> statements) to <code>raise ActiveRecord::RecordNotFound</code> if that fails, but it returns the 500 error before running the conditional (and therefor never returning a 404).</p>
  
  <p>Does anybody know a better way to handle that, or a way to allow the <code>Date.new</code> to fail more gracefully so that the conditional statement can run?</p>