I am new to Ruby. I am writing a Restful API application using Rails 4. How can I return 404 JSON string not found when the record is not found?
I found some posts, but no luck, only for Rails 3.
In my controller I can catch an exception
def show country = Country.find(params[:id]) render :json => country.to_record rescue Exception render :json => "404" end
But I want the shared one to capture all the unused resources.
ruby-on-rails-4
Kit Ho Apr 28 '14 at 4:06 on 2014-04-28 04:06
source share