This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
1
rescue_from ActiveRecord::RecordNotFound
Post Body
Good day, Im building an api in rails.
I have this method on my controller: def show @user = User.find(params[:id]) @http_status = 200 @http_response[:results] = @user json_render(@http_response, @http_status) end
with this exception handler:
rescue_from ActiveRecord::RecordNotFound do |e|
@http_response = e
@http_status = 404
render :json => @http_response, :status => @http_status
end
Is there a way to get the class from rescue_from ActiveRecord::RecordNotFound?
I want to render this json format:
{
"error":{
"user":[ "No order found" ]
}
}
This is what I'm getting:
{
"error": "Couldn't find User with 'id'=5",
}
Author
Account Strength
100%
Account Age
10 years
Verified Email
Yes
Verified Flair
No
Total Karma
5,078
Link Karma
2,929
Comment Karma
2,082
Profile updated: 3 days ago
Posts updated: 10 months ago
Subreddit
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 7 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/rails/comme...