Created
April 10, 2009 14:22
-
-
Save olkeene/93098 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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