The most basic thing to do is set the class variable from environment.rb. I did this for Google Analytics. Essentially, I need another key, depending on which environment I'm in such a development or stage without distorting the metrics.
Here is how I did it.
In lib/analytics/google_analytics.rb :
module Analytics class GoogleAnalytics @@account_id = nil cattr_accessor :account_id end end
And then in environment.rb or in environments/production.rb or in any other environment file:
Analytics::GoogleAnalytics.account_id = "xxxxxxxxx"
Then, wherever you reference, say, the default layout with the Google Analytics JavaScript, you simply call Analytics::GoogleAnalytics.account_id .
Otto
source share