-
-
Save Archimidis/6104523 to your computer and use it in GitHub Desktop.
Revisions
-
gonzedge revised this gist
Sep 24, 2012 . 1 changed file with 5 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,27 +2,15 @@ class ApplicationController < ActionController::Base # ... unless Rails.application.config.consider_all_requests_local rescue_from Exception, with: lambda { |exception| render_error 500, exception } rescue_from ActionController::RoutingError, ActionController::UnknownController, ::AbstractController::ActionNotFound, ActiveRecord::RecordNotFound, with: lambda { |exception| render_error 404, exception } end private def render_error(status, exception) respond_to do |format| format.html { render template: "errors/error_#{status}", layout: 'layouts/application', status: status } format.all { render nothing: true, status: status } end end -
gonzedge revised this gist
Apr 1, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1 @@ rails generate controller errors error_404 error_500 -
gonzedge revised this gist
Feb 6, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,15 +13,15 @@ class ApplicationController < ActionController::Base def render_404(exception) @not_found_path = exception.message respond_to do |format| format.html { render template: 'errors/error_404', layout: 'layouts/application', status: 404 } format.all { render nothing: true, status: 404 } end end def render_500(exception) @error = exception respond_to do |format| format.html { render template: 'errors/error_500', layout: 'layouts/application', status: 500 } format.all { render nothing: true, status: 500} end end -
gonzedge revised this gist
Jan 16, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,15 +10,15 @@ class ApplicationController < ActionController::Base end private def render_404(exception) @not_found_path = exception.message respond_to do |format| format.html { render template: 'errors/error_404', status: 404 } format.all { render nothing: true, status: 404 } end end def render_500(exception) @error = exception respond_to do |format| format.html { render template: 'errors/error_500', status: 500 } -
gonzedge created this gist
Jan 5, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ class ApplicationController < ActionController::Base # ... unless Rails.application.config.consider_all_requests_local rescue_from Exception, with: :render_500 rescue_from ActionController::RoutingError, with: :render_404 rescue_from ActionController::UnknownController, with: :render_404 rescue_from ActionController::UnknownAction, with: :render_404 rescue_from ActiveRecord::RecordNotFound, with: :render_404 end private def render_404(error) @not_found_path = exception.message respond_to do |format| format.html { render template: 'errors/error_404', status: 404 } format.all { render nothing: true, status: 404 } end end def render_500(error) @error = exception respond_to do |format| format.html { render template: 'errors/error_500', status: 500 } format.all { render nothing: true, status: 500} end end # ... end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ %h2 404 %div %h3 We're sorry %p The content that you requested could not be found. %p You tried to access '#{@not_found_path}', which is not a valid page. %p Want to %a{href: root_path} go back to our home page and try again? This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ class ErrorsController < ApplicationController def error_404 @not_found_path = params[:not_found] end def error_500 end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ rails generate controller errors error_404 error_505 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ get "errors/error_404" get "errors/error_500" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ unless Rails.application.config.consider_all_requests_local match '*not_found', to: 'errors#error_404' end