exception handling

Hi   I have controller edit action like

def edit   begin     @user = User.find(params[:id])    rescue ActiveRecord::RecordNotFound     logger.warn "User with id #{current_user.id} tried to edit user with id #{params[:id]}"     render :file => "#{RAILS_ROOT}/public/404.html"   else

Well you can specify a default page / controller action to perform for unmatched routes as well…so if the route doesn’t exist it shows a much user friendly page instead of the rails error message

Thanks & Regards,

Dhruva Sagar.

Hi   Thanks. But how can I handle in code?

Tom

Hi,

In application controller

rescue_from ActiveRecord::RecordNotFound,ActionController::RoutingError,              ActionController::UnknownController, ActionController::UnknownAction, ::NoMethodError,              :with => :handle_exception

# To handle Exceptions   def handle_exception     redirect_to no_access_url # redirect to a page with u need show   end