Using responders gem with Rails 5 : <p>I'm using <a href="https://github.com/plataformatec/responders" rel="noreferrer"><strong>responders gem</strong></a> to dry up my controllers. Here's my current code: </p>

<pre><code>class OfficehoursController &lt; ApplicationController
  def new
    @officehour = Officehour.new
  end

  def create
    @officehour = Officehour.create(officehour_params)

    respond_with(@officehour, location: officehours_path)
  end

  def officehour_params
    params.require(:officehour).permit(:end, :start, :status)
  end
end
</code></pre>

<p>The problem that I'm facing right now is:</p>

<p>When I send valid parameters to <code>create</code>, it redirects to <code>officehours/</code> as expected, however when I get 422 (validation error), it changes the URL from <code>officehours/new</code> to <code>officehours/</code> (however it stays at the form page... idk why). The same happens for edit/update actions.</p>

<p>So, I want to stay at the <code>.../new</code> or <code>.../edit</code> when I get 422 error, how can I do this?</p>
