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

Extra config sources defined in initializer #124

Open
DannyBen opened this issue Jan 1, 2016 · 3 comments
Open

Extra config sources defined in initializer #124

DannyBen opened this issue Jan 1, 2016 · 3 comments

Comments

@DannyBen
Copy link

DannyBen commented Jan 1, 2016

Hi,

Not sure if this is implemented and I haven't found it or not.

I know there is a way to create an initializer that adds another settings file and reloads.

Although this is a good feature that can solve my use case of loading config file per client, it feels a little "after the fact patch" since I dont really need it to be "at run time".

I was wondering if it will be difficult to add a more natural way of adding settings file at initialization time, simply as an option to the initializer, something like:

Config.setup do |config|
  config.const_name = "Settings"
  config.add_source = "config/settings/#{ENV['CLIENT_NAME']}.yml"
end

As a side note - where is the documentation of all the allowed options in the Config.setup block?

@pkuczynski
Copy link
Member

Settings constant is a singleton shared across all request to your Rails app. That means it would load your client config once when the server starts (single Rails server instance serving single client). Is this what you are trying to achieve?

In contrast you might want to apply custom client settings per every request, so one server can respond to multiple clients...

@ilyakarol
Copy link

@pkuczynski it would be nice improvement in terms of splitting different config files by domains/technologies. Big config file is difficult for reading/understanding, is there a chance for implementing this feature?

@pkuczynski
Copy link
Member

@IlyaKorol you can add sources in runtime. It should not be hard to do the same on the initializer level as @DannyBen suggested:

Config.setup do |config|
  config.const_name = "Settings"
  config.extra_sources = [...]
end

Feel free to create PR for this feature and we will merge it.

@pkuczynski pkuczynski changed the title Feature Request: Append to files list at initializer Extra config sources defined in initializer Jul 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants