New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
respond_with doesn't accept statuses on PUT requests #9069
Comments
Is that valid to the http protocol to respond with 404 while passing a |
Probably not. But if you remove the |
For what it's worth, the behavior is similar on master. |
@Dru89 - this appears to be intentional. It's expected to that |
Should this be intentional, though? I'm not entirely sure. I don't think it should be intentional to return a success code when you're really wanting to show the user had an error. Especially since it's a
Also, @et, can you link to the source where you found that? I'm digging for myself, but I can't seem to find where it's actually applying the settings. Thanks! |
First of all, returning a 404 from a That said, this does seem to be a weird edge case. |
@steveklabnik Also, 404 makes a lot of sense for def update
account = Account.where(id: params[:id]).first
unless account.nil?
# update account
else
# respond with 404 message and custom error, because that account doesn't exist.
end
end You could use |
@Dru89 no, |
@Dru89 @steveklabnik Look here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html Directly from there:
Also, on the topic of 404 and other status codes, you can't use Anyway, getting back on the ground, why would you immediately |
Right. Ultimately, there's something funky with Rails, regardless of the specific status code and its meaning. |
As for why you would immediately
|
Any update on this? |
Is the convention here that after updating a resource, you have to fetch the resource again to see if it was successfully updated? It seems that returning a 422 in the case that the record not being updated would be the most efficient use of bandwidth and least confusing. From the aforementioned spec, "If the resource could not be created or modified with the Request-URI, an appropriate error response SHOULD be given that reflects the nature of the problem." Should an appropriate error response include being able to return the status code appropriate for the response message? For example
seems like an appropriate response when updating a record without the requisite foreign keys. |
Any info on this? |
+1 I need 422 in my current projects. It's strange decision to always return 204 =/ |
Any updates on this? |
This issue has been automatically marked as stale because it has not been commented on for at least The resources of the Rails team are limited, and so we are asking for your help. If you can still reproduce this error on the Thank you for all your contributions. |
This issue has been automatically closed because of inactivity. If you can still reproduce this error on the Thank you for all your contributions. |
Given the following controller,
and a routing rule of
resources :accounts
I would expect to see a status of 404 from a curl request, like the following:
However, it instead returns the following:
The following use of
respond_with
also does not work:Using
respond_to
does work, though.I believe that
respond_with
is broken in this way.The version of rails that I'm using is 3.2.11
The text was updated successfully, but these errors were encountered: