Skip to content
Browse files

added heroku config rake task for variables and added session to load…

… from ENV if file for secret does not exist
  • Loading branch information...
1 parent 670d1a2 commit 532f1e071c6a3e11fb9d1e84c6d3e6c0cf4c190c @stevenhaddox committed Jun 13, 2010
Showing with 25 additions and 3 deletions.
  1. +11 −2 config/initializers/session_store.rb
  2. +14 −1 lib/tasks/config.rake
View
13 config/initializers/session_store.rb
@@ -4,9 +4,18 @@
# If you change this key, all old sessions will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
+secret = File.read(File.join(RAILS_ROOT, 'config/secret')).strip
+unless secret
+ if Rails.env == 'production'
+ secret = ENV['SECRET']
+ else
+ secret = ENV['F4T_SECRET']
+ end
+end
+
ActionController::Base.session = {
- :key => '_tweetie_flickr_session',
- :secret => File.read(File.join(RAILS_ROOT, 'config/secret')).strip
+ :key => '_flickr4twitter_session',
+ :secret => secret
}
# Use the database for sessions instead of the cookie-based default,
View
15 lib/tasks/config.rake
@@ -40,7 +40,20 @@ END_TWITTER
file.write twitter_config
end
end
-
+
+ desc 'Push _local_ ENV config settings to heroku'
+ task :heroku do
+ ENV_VARS = {
+ 'FLICKR_KEY' => ENV['F4T_FLICKR_KEY'],
+ 'FLICKR_SECRET' => ENV['F4T_FLICKR_SECRET'],
+ 'SECRET' => File.read("#{Rails.root}/config/secret"),
+ 'TWITTER_TOKEN' => ENV['F4T_TWITTER_TOKEN'],
+ 'TWITTER_SECRET' => ENV['F4T_TWITTER_SECRET']
+ }
+ command = "heroku config:add"
+ ENV_VARS.each {|key, val| command << " #{key}=#{val} " if val }
+ system command
+ end
end

0 comments on commit 532f1e0

Please sign in to comment.
Something went wrong with that request. Please try again.