I'm using responders gem to dry up my controllers. Here's my current code:
class OfficehoursController < 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
The problem that I'm facing right now is:
When I send valid parameters to create
, it redirects to officehours/
as expected, however when I get 422 (validation error), it changes the URL from officehours/new
to officehours/
(however it stays at the form page... idk why). The same happens for edit/update actions.
So, I want to stay at the .../new
or .../edit
when I get 422 error, how can I do this?