proper error messages
git-svn-id: http://svn.barleysodas.com/barleysodas/trunk@19 0f7b21a7-9e3a-4941-bbeb-ce5c7c368fa7master
parent
bb312db094
commit
6696d65f6e
|
@ -1,3 +1,21 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
session :session_key => '_barleysodas_session_id'
|
||||
end
|
||||
|
||||
##
|
||||
# Sane error and missing document messages.
|
||||
#
|
||||
def rescue_action_in_public(exception)
|
||||
logger.debug("#{exception.class.name}: #{exception.to_s}")
|
||||
exception.backtrace.each { |bt| logger.debug "! #{bt}" }
|
||||
case exception
|
||||
when ::ActiveRecord::RecordNotFound,
|
||||
::ActionController::UnknownController,
|
||||
::ActionController::UnknownAction,
|
||||
::ActionController::RoutingError
|
||||
render :file => File.join(RAILS_ROOT, 'public/404.html'),
|
||||
:status => '404 Not Found'
|
||||
else
|
||||
render :file => File.join(RAILS_ROOT, 'public/500.html'),
|
||||
:status => '500 Error'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -83,6 +83,7 @@ class BeersController < ApplicationController
|
|||
def get_beer_and_page
|
||||
@beer = Beer.find_by_title(Page.title_from_url(params[:id]),
|
||||
:include => [ 'page' ])
|
||||
raise ActiveRecord::RecordNotFound.new if @beer.nil?
|
||||
@page = @beer.page
|
||||
end
|
||||
end
|
||||
|
|
|
@ -85,5 +85,6 @@ class PagesController < ApplicationController
|
|||
|
||||
def fetch_page
|
||||
@page = Page.find_by_title(Page.title_from_url(params[:id]))
|
||||
raise ActiveRecord::RecordNotFound.new if @page.nil?
|
||||
end
|
||||
end
|
||||
|
|
Reference in New Issue