The Wayback Machine - https://web.archive.org/web/20201210222607/https://github.com/rubyconfig/config/issues/286
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow symbol value via ENV #286

Open
khoan opened this issue Nov 9, 2020 · 2 comments
Open

Allow symbol value via ENV #286

khoan opened this issue Nov 9, 2020 · 2 comments

Comments

@khoan
Copy link

@khoan khoan commented Nov 9, 2020

Setup

cd /path/to/rails/app/src
cat config/initializers/config.rb
Config.setup do |config|
  config.const_name = 'Settings'
  config.use_env = true
  config.env_prefix = 'SETTINGS'
  config.env_separator = '__'
  config.env_converter = :downcase
  config.env_parse_values = true
end
cat config/settings/test.yml
provider: :bam
SETTINGS__PROVIDER=:bam RAILS_ENV=test bin/rails c
Settings.provider # => ":bam"   want symbol instead of string
RAILS_ENV=test bin/rails c
Settings.provider # => :bam  got symbol as expected

maybe related to issue#194? Thanks.

@pkuczynski
Copy link
Member

@pkuczynski pkuczynski commented Nov 9, 2020

I don't think its related to #194. They actually wanted something opposite to your case.

Env vars are string and I don't think we should force conversion to symbols. However we could implement a logic where strings staring from : would be converted to symbols (see: https://stackoverflow.com/questions/2004491/convert-string-to-symbol-able-in-ruby)

If you are interested, maybe you can fire up a PR?

@pkuczynski pkuczynski changed the title allow symbol value via ENV Allow symbol value via ENV Nov 9, 2020
@pkuczynski
Copy link
Member

@pkuczynski pkuczynski commented Dec 8, 2020

@khoan are you interested in firing up PR for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.