Skip to content

Commit

Permalink
Added README describing Heroku local config workflow. Refs rubyconfig#56
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidelnikov Stanislav committed Nov 15, 2013
1 parent 017bd98 commit 2f984cd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,30 @@ Settings.reload!
> Note: this is an example usage, it is easier to just use the default local files `settings.local.yml, settings/#{Rails.env}.local.yml and environments/#{Rails.env}.local.yml`
> for your developer specific settings.
## Working with Heroku

Heroku uses ENV object to store sensitive settings which are like the local files described above. You cannot upload such files to Heroku because it's ephemeral filesystem gets recreated from the git sources on each instance refresh.

To use rails_config with Heroku just set the `use_env` var to `true` in your `config/initializers/rails_config.rb` file. Eg:

```ruby
RailsConfig.setup do |config|
config.const_name = 'AppSettings'
config.use_env = true
end
```

Now rails_config would read values from the ENV object to the settings. For the example above it would look for keys starting with 'AppSettings'. Eg:

```ruby
ENV['AppSettings.section.size'] = 1
ENV['AppSettings.section.server'] = 'google.com'
```

It won't work with arrays, though.

To upload your local values to Heroku you could ran `bundle exec rake rails_config:heroku`.

## Embedded Ruby (ERB)

Embedded Ruby is allowed in the configuration files. See examples below.
Expand Down
3 changes: 0 additions & 3 deletions lib/rails_config/tasks/task.rake

This file was deleted.

4 changes: 1 addition & 3 deletions lib/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def vars
)

out = ''
hash = {RailsConfig.const_name => Kernel.const_get(RailsConfig.const_name).to_hash}
dotted_hash = to_dotted_hash hash
dotted_hash = to_dotted_hash Kernel.const_get(RailsConfig.const_name).to_hash, {}, RailsConfig.const_name
dotted_hash.each {|key, value| out += " #{key}=#{value} "}
out
end
Expand All @@ -33,7 +32,6 @@ def environment
def heroku(command)
with_app = app ? " --app #{app}" : ""
`heroku #{command}#{with_app}`
#puts "heroku #{command}#{with_app}"
end

def `(command)
Expand Down

0 comments on commit 2f984cd

Please sign in to comment.