Commit 6c1bd3d30c433159fced61b1cd4f8ea1973a84c4

Authored by Winfield Peterson
1 parent 6254489b
Exists in master

Document new suppress_errors option.

Showing 1 changed file with 16 additions and 0 deletions   Show diff stats
README.rdoc
... ... @@ -114,6 +114,22 @@ Modifying our model example:
114 114 This would allow you to specify a custom value for per_page just for posts, or
115 115 to fall back to your default value if not specified.
116 116  
  117 +=== 4. Suppressing Exceptions Conditionally
  118 +
  119 +Raising exceptions for missing settings helps highlight configuration problems. However, in a
  120 +Rails app it may make sense to suppress this in production and return nil for missing settings.
  121 +While it's useful to stop and highlight an error in development or test environments, this is
  122 +often not the right answer for production.
  123 +
  124 + class Settings < Settingslogic
  125 + source "#{Rails.root}/config/application.yml"
  126 + namespace Rails.env
  127 + suppress_errors Rails.env.production?
  128 + end
  129 +
  130 + >> Settings.non_existent_key
  131 + => nil
  132 +
117 133 == Note on Sinatra / Capistrano / Vlad
118 134  
119 135 Each of these frameworks uses a +set+ convention for settings, which actually defines methods
... ...