Using Responder Stones with Rails 5

I use responseers gem to dry my controllers. Here is 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 I'm facing right now:

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 remains on the form page .. . idk why). The same thing happens for edit / update actions.

So, I want to stay on .../new or .../edit when I get error 422, how can I do this?

+5
source share
1 answer

I don't think this is a problem in the response camcorder, as I noticed the same thing in rails applications. This seems to be the default behavior for rail applications. look at the link for an explanation.

0
source

Source: https://habr.com/ru/post/1276073/


All Articles