Skip to content

Commit 6c1bd3d

Browse files
author
Winfield Peterson
committed
Document new suppress_errors option.
1 parent 6254489 commit 6c1bd3d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.rdoc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,22 @@ Modifying our model example:
114114
This would allow you to specify a custom value for per_page just for posts, or
115115
to fall back to your default value if not specified.
116116

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+
117133
== Note on Sinatra / Capistrano / Vlad
118134

119135
Each of these frameworks uses a +set+ convention for settings, which actually defines methods

0 commit comments

Comments
 (0)