Reputation: 458
for ex: I type the url: localhost:3000/hoasung01 then it throws a message:
Unknown action
The action 'hoasung01' could not be found for StaticController
And in console:
AbstractController::ActionNotFound (The action 'hoasung01' could not be found for StaticController):
I spent many hours to research and try some ways:
rescue_from AbstractController::ActionNotFound, with: :page_not_found
#(ActionController::RoutingError, ActionController::UnknownController, ::AbstractController::ActionNotFound, ActiveRecord::RecordNotFound)
protected
def page_not_found
render 'layouts/404.html', :status => 403, :layout => false
end
but it does not render 404.html page. ( I use rails 4.1.5 )
Upvotes: 1
Views: 42
Reputation: 2987
In development you are shown a special error page to help you figure out errors. I you want to test that 404
and 500
s work look at this blog post: http://thepugautomatic.com/2014/08/404-with-rails-4/
The section Verify in development says t config/environments/development.rb
and add the following line:
config.consider_all_requests_local = false
Upvotes: 2