Skip to content

Instantly share code, notes, and snippets.

@olkeene
Created April 10, 2009 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olkeene/93098 to your computer and use it in GitHub Desktop.
Save olkeene/93098 to your computer and use it in GitHub Desktop.
class ActionController::Base
private
def rescue_action_in_public(exception)
respond_to do |want|
want.html {
super(exception)
}
want.js {
render :update do |page|
page.alert "We're sorry, but something went wrong.\nWe've been notified about this issue and we'll take a look at it shortly.\n\nPlease check that any update you tried has not been successful before trying it again."
end
}
end
end
def rescue_action_locally(exception)
respond_to do |want|
want.html {
super(exception)
}
want.js {
render :update do |page|
page.alert "Oops! I made a mistake\n#{exception.class}: #{exception.message}\nCheck the logs for more detail."
end
}
end
end
end
# used in deploy.rb too
REQUIRED_CONFIG_FILES = ['config/database.yml']
root_path = defined?(Rails) ? Rails.root : "#{File.dirname(__FILE__)}/../.."
REQUIRED_CONFIG_FILES.each do |f|
raise Exception, "config file #{f} missed" unless File.exist? File.join(root_path, f)
end
if Rails.env.development?
ActiveRecord::Base.class_eval do
def log_protected_attribute_removal(*attributes)
raise "Can't mass-assign these protected attributes: #{attributes.join(', ')}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment