diff --git a/.gitignore b/.gitignore index 1ed6eb9..b713bec 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ /tmp # Local settings -/config/settings_development.yml +/config/settings.yml # Misc .DS_Store diff --git a/app/models/submission.rb b/app/models/submission.rb index 45fc965..687ab9b 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -21,7 +21,7 @@ def create_service_request lat, long = Geocoder.coordinates("#{self.restaurant_address} , Chicago, IL") HTTParty.post('http://test311api.cityofchicago.org/open311/v2/requests.json', :body => { - :api_key => SETTINGS["311_api_key"], + :api_key => SETTINGS["OPEN_311_KEY"], :service_code => '4fd6e4ece750840569000019', :attribute => { :PLEASESE => 'FOODPOIS', diff --git a/config/initializers/settings.rb b/config/initializers/settings.rb index 6ff4a4a..26a9d29 100644 --- a/config/initializers/settings.rb +++ b/config/initializers/settings.rb @@ -1 +1,3 @@ -SETTINGS = YAML.load_file("#{Rails.root}/config/settings_#{Rails.env}.yml") \ No newline at end of file +# Load the settings file, or grab them from ENV +settings_file = "#{Rails.root}/config/settings.yml" +SETTINGS = File.exist?(settings_file) ? YAML.load_file(settings_file) : ENV \ No newline at end of file diff --git a/config/initializers/twitter.rb b/config/initializers/twitter.rb index 5efa582..b4e4f31 100644 --- a/config/initializers/twitter.rb +++ b/config/initializers/twitter.rb @@ -1,6 +1,6 @@ Twitter.configure do |config| - config.consumer_key = SETTINGS["twitter"]["consumer_key"] - config.consumer_secret = SETTINGS["twitter"]["consumer_secret"] - config.oauth_token = SETTINGS["twitter"]["access_token"] - config.oauth_token_secret = SETTINGS["twitter"]["access_secret"] + config.consumer_key = SETTINGS["TWITTER_CONSUMER_KEY"] + config.consumer_secret = SETTINGS["TWITTER_CONSUMER_SECRET"] + config.oauth_token = SETTINGS["TWITTER_ACCESS_TOKEN"] + config.oauth_token_secret = SETTINGS["TWITTER_ACCESS_SECRET"] end \ No newline at end of file diff --git a/config/settings.yml.example b/config/settings.yml.example new file mode 100644 index 0000000..4b15846 --- /dev/null +++ b/config/settings.yml.example @@ -0,0 +1,10 @@ +# SETTINGS +# Copy the contents of file into a new file named "settings.yml", +# and fill in your Open 311 and Twitter API keys + +OPEN_311_KEY: + +TWITTER_CONSUMER_KEY: +TWITTER_CONSUMER_SECRET: +TWITTER_ACCESS_TOKEN: +TWITTER_ACCESS_SECRET: \ No newline at end of file diff --git a/config/settings_development.yml.example b/config/settings_development.yml.example deleted file mode 100644 index 12392e8..0000000 --- a/config/settings_development.yml.example +++ /dev/null @@ -1,6 +0,0 @@ -311_api_key: -twitter: - consumer_key: - consumer_secret: - access_token: - access_secret: \ No newline at end of file diff --git a/config/settings_production.yml b/config/settings_production.yml deleted file mode 100644 index 2bbf823..0000000 --- a/config/settings_production.yml +++ /dev/null @@ -1,6 +0,0 @@ -311_api_key: ENV["311_API_KEY"] -twitter: - consumer_key: ENV["TWITTER_CONSUMER_KEY"] - consumer_secret: ENV["TWITTER_CONSUMER_SECRET"] - access_token: ENV["TWITTER_ACCESS_TOKEN"] - access_secret: ENV["TWITTER_ACCESS_SECRET"] \ No newline at end of file