Created
June 30, 2011 13:31
-
-
Save brianburridge/1056243 to your computer and use it in GitHub Desktop.
An easy and flexible way to set global variables for a Rails app using Ostruct.
This file contains hidden or 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
require "ostruct" | |
case RAILS_ENV | |
when "staging" | |
google_maps_key = 'staging google maps key' | |
support_email = '[email protected]' | |
ssl_subdomain = 'secure' | |
original_subdomain = 'www' | |
when "production" | |
google_maps_key = 'production google maps key' | |
support_email = '[email protected]' | |
ssl_subdomain = 'secure' | |
original_subdomain = 'www' | |
else | |
support_email = 'localhost' | |
google_maps_key = 'development google maps key' | |
ssl_subdomain = 'secure' | |
original_subdomain = 'www' | |
end | |
App = OpenStruct.new({ | |
:settings => OpenStruct.new({ | |
:page_limit => 25, | |
:ssl_subdomain => ssl_subdomain, | |
:original_subdomain => original_subdomain, | |
:google_maps_key => google_maps_key, | |
:support_email => support_email, | |
:html_default_title => 'Site Title' | |
}) | |
}) | |
# Use App.settings.page_limit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment