404 handling
This commit is contained in:
parent
139d6144de
commit
2abdf89511
3
app/assets/javascripts/exceptions.js.coffee
Normal file
3
app/assets/javascripts/exceptions.js.coffee
Normal file
@ -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/
|
3
app/assets/stylesheets/exceptions.css.scss
Normal file
3
app/assets/stylesheets/exceptions.css.scss
Normal file
@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the exceptions controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
@ -1,3 +1,7 @@
|
||||
class NotFound < StandardError; end
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
rescue_from(NotFound) { render 'exceptions/not_found' }
|
||||
|
||||
end
|
||||
|
10
app/controllers/exceptions_controller.rb
Normal file
10
app/controllers/exceptions_controller.rb
Normal file
@ -0,0 +1,10 @@
|
||||
class ExceptionsController < ApplicationController
|
||||
|
||||
def not_found
|
||||
respond_to do |format|
|
||||
format.any { render :text => 'Requested resource not found', :status => 404 }
|
||||
format.html { render :status => 404 }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
2
app/helpers/exceptions_helper.rb
Normal file
2
app/helpers/exceptions_helper.rb
Normal file
@ -0,0 +1,2 @@
|
||||
module ExceptionsHelper
|
||||
end
|
1
app/views/exceptions/not_found.html.erb
Normal file
1
app/views/exceptions/not_found.html.erb
Normal file
@ -0,0 +1 @@
|
||||
404 dude
|
@ -55,4 +55,6 @@ AsciiIo::Application.routes.draw do
|
||||
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
||||
# Note: This route will make all actions in every controller accessible via GET requests.
|
||||
# match ':controller(/:action(/:id(.:format)))'
|
||||
|
||||
match "*a", :to => "exceptions#not_found"
|
||||
end
|
||||
|
5
spec/controllers/exceptions_controller_spec.rb
Normal file
5
spec/controllers/exceptions_controller_spec.rb
Normal file
@ -0,0 +1,5 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe ExceptionsController do
|
||||
|
||||
end
|
15
spec/helpers/exceptions_helper_spec.rb
Normal file
15
spec/helpers/exceptions_helper_spec.rb
Normal file
@ -0,0 +1,15 @@
|
||||
require 'spec_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the ExceptionsHelper. For example:
|
||||
#
|
||||
# describe ExceptionsHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# helper.concat_strings("this","that").should == "this that"
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
describe ExceptionsHelper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue
Block a user