end
end
-=begin
- rescue_from ActiveRecord::RecordNotFound, :with => :render_404
-
- private
- def render_404(exception = nil)
- if exception
+ if Rails.env == 'production'
+ rescue_from ActiveRecord::RecordNotFound, :with => :render_404
+ rescue_from ActiveRecord::Forbidden, :with => :render_403
+
+ private
+ def render_404(exception = nil)
+ if exception
logger.info "Rendering 404: #{exception.message}"
+ end
+ respond_to do |format|
+ format.html {
+ render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
+ }
+ format.json {
+ render :text => "404 Not found", :status => 404
+ }
+ end
+ end
+
+ def render_403(exception = nil)
+ if exception
+ logger.info "Rendering 403: #{exception.message}"
+ end
+ respond_to do |format|
+ format.html {
+ render :file => "#{Rails.root}/public/403.html", :status => 404, :layout => false
+ }
+ format.json {
+ render :text => "403 Forbidden", :status => 403
+ }
+ end
end
- respond_to do |format|
- format.html {
- render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
-}
- format.json {
- render :text => "404 found", :status => 404
-}
- end
end
-=end
end