You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading from 3.0.1 to 3.1.0 I found some changes in logic regarding providing status to respond_with.
I need to change status for a couple of actions for Hotwire/Turbo usage. There is new configuration option responders.error_status, but there is no need to set it as a default for the whole application in some cases.
I have update action in my controller:
def update
@product.update(product_params) #it will add errors on invalid params
respond_with @product, location: [:dashboard], action: :show, status: 422
end
When I was using 3.0.1 if it has errors it returns status 422, as provided.
After moving to 3.1.0 this doesn't work and status set as default 200 OK.
I didn't find in changelog that providing status via options doesn't work any more.
I found possible problem inside error_rendering_options:
def to_html
default_render
rescue ActionView::MissingTemplate => e
navigation_behavior(e) # <-- here
end
def navigation_behavior(error)
if get?
raise error
elsif has_errors? && default_action
render error_rendering_options # <-- here
else
redirect_to navigation_location, status: redirect_status
end
end
def error_rendering_options
if options[:render]
options[:render]
else
{ action: default_action, status: error_status } # <-- here
end
end
It works as previously when I tried to change it locally to:
After upgrading from
3.0.1
to3.1.0
I found some changes in logic regarding providing status torespond_with
.I need to change status for a couple of actions for Hotwire/Turbo usage. There is new configuration option
responders.error_status
, but there is no need to set it as a default for the whole application in some cases.I have update action in my controller:
When I was using
3.0.1
if it has errors it returns status 422, as provided.After moving to
3.1.0
this doesn't work and status set as default200 OK
.I didn't find in changelog that providing status via options doesn't work any more.
I found possible problem inside
error_rendering_options
:It works as previously when I tried to change it locally to:
And probably for redirects there is possibility of the same issue and, it could be:
The text was updated successfully, but these errors were encountered: