I want to catch unknown action error in Rails 3, that shows \"Unknown Action\" error on development and the 404.html on production. I tried putting this rescue_from
If you really want to rescue AbstractController::ActionNotFound
in a controller, you can try something like this:
class UsersController < ApplicationController
private
def process(action, *args)
super
rescue AbstractController::ActionNotFound
respond_to do |format|
format.html { render :404, status: :not_found }
format.all { render nothing: true, status: :not_found }
end
end
public
# actions must not be private
end
This overrides the process
method of AbstractController::Base
that raises AbstractController::ActionNotFound
(see source).