Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Added config.prepend_sources option to Config.setup #142
Conversation
|
@tjgfernandes, could you please add some documentation explaining this new feature? I honestly see no use case, so I am interested to see how you present it... |
|
@pkuczynski, need to prepend custom yml setting file that depends on ENV variable to be sure that all settings dependencies are loaded based on that custom yml file. This way settings just run once, for me it's more clean/clear than using runtime approach. Also, any initializer i have can use Settings. This way you can choose to prepend_source at config time or runtime. |
|
So the idea you have is to be able to load another settings file before loading current set of files based on the current environment? Sorry for asking, but why would you like to do that? More natural feels: load default settings and then override some of them with custom file based on ENV variable... Could you please elaborate a little bit more on this, as I would like to better understand the reasoning before merging this into master. |
|
@pkuczynski i see your point but don't see it as more natural. config.prepend_sources allows to have pre custom settings without worring to create another initializer to add_and_reload source. Configuration is done is one place and it runs once. Don't need to worry to what happens with Rails app and settings usage/dependencies in between Config initialize and source_added_and_reloaded! (even for a very short time). Settings may be updated on reload! but what happens with any config you might have passed the previous Settings value inside the Rails app? note: The other way to do this would be to allow to config settings files at config time, but didn't have that need, settings.yml file and others are fine has they are. |
|
@pkuczynski, have pull request this because i was thinking it might be a small change that could be useful. But if this isn't something you see usefull for railsconfig users, please don't merge. No problem on my side! |
|
I see your point, but I am not sure about the implementation. Let me think about it for a while and abstract it in a more general way, where you can update which files are loaded in which order in a simple and clean way. I do not like |
|
@pkuczynski any update on this? This feature is very useful for my team, coz I work on apps with lots of yaml settings, that most of the time are not environment based, so we break up the settings into smaller yaml files e.g. Ideally we should also have an |
|
Apologies. I will have a look tomorrow. |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

No description provided.