Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added placeholder error pages to i18n

  • Loading branch information...
commit 64a358dac27c854e972994e81367c533c0c43a31 1 parent 6c11a1a
nicolassatragno authored
View
4 Gemfile
@@ -11,13 +11,13 @@ gem 'sqlite3'
gem 'fast_gettext'
gem 'gettext_i18n_rails', '>= 0.4.3'
gem 'rails-i18n'
+gem 'sass-rails', '~> 3.2.3'
+gem 'bootstrap-sass', '~> 2.0.0'
group :assets do
- gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'therubyracer', :platform => :ruby
gem 'uglifier', '>= 1.0.3'
- gem 'bootstrap-sass', '~> 2.0.0'
end
gem 'jquery-rails'
View
3  app/assets/javascripts/errors.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
View
3  app/assets/stylesheets/errors.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the errors controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
View
13 app/controllers/application_controller.rb
@@ -3,4 +3,17 @@ class ApplicationController < ActionController::Base
include FastGettext::Translation
before_filter :set_gettext_locale
+
+ 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
end
View
8 app/controllers/errors_controller.rb
@@ -0,0 +1,8 @@
+class ErrorsController < ApplicationController
+ def error_404
+ @not_found_path = params[:not_found]
+ end
+
+ def error_500
+ end
+end
View
2  app/helpers/errors_helper.rb
@@ -0,0 +1,2 @@
+module ErrorsHelper
+end
View
1  app/views/errors/error_404.html.erb
@@ -0,0 +1 @@
+Error 404
View
1  app/views/errors/error_500.html.haml
@@ -0,0 +1 @@
+Error 500
View
4 config/routes.rb
@@ -36,6 +36,10 @@
post :gemfile_tool, :on => :collection
end
+# unless Rails.application.config.consider_all_requests_local
+ match '*not_found', to: 'errors#error_404'
+# end
+
# The priority is based upon order of creation:
# first created -> highest priority.
View
19 spec/controllers/errors_controller_spec.rb
@@ -0,0 +1,19 @@
+require 'spec_helper'
+
+describe ErrorsController do
+
+ describe "GET 'error_404'" do
+ it "returns http success" do
+ get 'error_404'
+ response.should be_success
+ end
+ end
+
+ describe "GET 'error_500'" do
+ it "returns http success" do
+ get 'error_500'
+ response.should be_success
+ end
+ end
+
+end
View
15 spec/helpers/errors_helper_spec.rb
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+# Specs in this file have access to a helper object that includes
+# the ErrorsHelper. For example:
+#
+# describe ErrorsHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# helper.concat_strings("this","that").should == "this that"
+# end
+# end
+# end
+describe ErrorsHelper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
View
5 spec/views/errors/error_404.html.haml_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe "errors/error_404.html.haml" do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
View
5 spec/views/errors/error_500.html.haml_spec.rb
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe "errors/error_500.html.haml" do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
Please sign in to comment.
Something went wrong with that request. Please try again.