Permalink
Browse files

using http://tammersaleh.com/posts/managing-heroku-environment-variab…

…les-for-local-development to hide app credentials in the github repo
  • Loading branch information...
1 parent 2048790 commit cf061c1c5e0370d4784d43f57f2debd98d56546c @pierrevalade committed Apr 29, 2011
Showing with 18 additions and 11 deletions.
  1. +2 −1 .gitignore
  2. +1 −1 Gemfile
  3. +0 −4 Gemfile.lock
  4. +7 −2 app/controllers/application_controller.rb
  5. +2 −2 config/application.yml
  6. +5 −0 config/environment.rb
  7. +0 −1 github/ignore
  8. +1 −0 vendor/plugins/quimby
View
3 .gitignore
@@ -1,4 +1,5 @@
.bundle
db/*.sqlite3
log/*.log
-tmp/**/*
+tmp/**/*
+config/heroku_env.rb
View
2 Gemfile
@@ -35,4 +35,4 @@ gem "haml"
gem "json"
gem "typhoeus"
-gem "quimby", :require => 'foursquare'
+# gem "quimby"
View
4 Gemfile.lock
@@ -42,9 +42,6 @@ GEM
treetop (~> 1.4.8)
mime-types (1.16)
polyglot (0.3.1)
- quimby (0.4.0)
- json
- typhoeus
rack (1.2.2)
rack-mount (0.6.14)
rack (>= 1.0.0)
@@ -82,7 +79,6 @@ PLATFORMS
DEPENDENCIES
haml
json
- quimby
rails (= 3.0.3)
settingslogic
sqlite3-ruby
View
9 app/controllers/application_controller.rb
@@ -14,11 +14,16 @@ def require_user
def current_user
return nil if session[:access_token].blank?
- @current_user ||= foursquare.users.find("self")
+ begin
+ foursquare = Foursquare::Base.new(session[:access_token])
+ @current_user ||= foursquare.users.find("self")
+ rescue Foursquare::InvalidAuth
+ nil
+ end
end
def foursquare
- if session[:access_token].blank?
+ unless current_user
@foursquare ||= Foursquare::Base.new(Settings.app_id, Settings.app_secret)
else
@foursquare ||= Foursquare::Base.new(session[:access_token])
View
4 config/application.yml
@@ -1,6 +1,6 @@
defaults: &defaults
- app_id: EJFXLWLZVKG3BU541MRTQG0KGJ2AXNYRQYMMD1UZF2MSH1N5
- app_secret: D1ZM1SX4NXSKAZ5R5NF10JZRFJPLMJJBEMDRPMVD5FFDCO3I
+ app_id: <%= ENV['FOURSQUARE_APP_ID'] %>
+ app_secret: <%= ENV['FOURSQUARE_APP_SECRET'] %>
development:
<<: *defaults
View
5 config/environment.rb
@@ -1,5 +1,10 @@
# Load the rails application
require File.expand_path('../application', __FILE__)
+# Load heroku vars from local file
+# http://tammersaleh.com/posts/managing-heroku-environment-variables-for-local-development
+heroku_env = File.join(Rails.root.to_s, 'config', 'heroku_env.rb')
+load(heroku_env) if File.exists?(heroku_env)
+
# Initialize the rails application
FoursquareSpeed::Application.initialize!
View
1 github/ignore
@@ -1 +0,0 @@
-../config/application.yml
1 vendor/plugins/quimby
@@ -0,0 +1 @@
+Subproject commit efbf6d5f0992fd8969b44f25467ccf48fbae2843

0 comments on commit cf061c1

Please sign in to comment.