markbates / configatron

A super cool, simple, and feature rich configuration system for Ruby apps.

Home Page:http://www.metabates.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multi-project configuration loaded from a rails engine?

mhenrixon opened this issue · comments

Hi,

I don't want to duplicate the configuration in my many projects that they all should share anyway so was trying to use configatron for this but something is failing.

inside the rails engine I have config/configatron/*.rb one of those files could look like:

# config/configatron/development.rb
configatron.hosts do |hosts|
  hosts.api   = "http://localhost:3000/"
  hosts.admin = "http://localhost:3001/"
  hosts.jobs  = "http://localhost:3002/"
  hosts.web   = "https://localhost:3006/"
end

The project is a rails engine so no initializer here since that won't work but in my spec/dummy and projects using the engine I have the following initializer.

# config/initializers/configatron.rb
require 'configatron'
Configatron::Rails.init CasinoSaga::Engine.root.join('config', 'configatron')

This works for a few things. If I load it locally and check the rails console I've got values there but on Heroku and when running tests all the values are blank. Any ideas why that is happening and how I might fix it? I thought simply running Configatron::Rails.init CasinoSaga::Engine.root.join('config', 'configatron') would fix any such problem but configatron isn't initialized ok anyway. Using 3.rc something version. Should I downgrade to V2?

I switched to version 2.13.0 and just load the specifc environment file with the below fixes the problem but I have absolutely no idea why that won't work in 3.0.0.rc1.

# config/initializers/configatron.rb
require 'configatron'
Configatron::Rails.init CasinoSaga::Engine.root.join('config', 'configatron', "#{Rails.env}.rb")

Could I please pretty please get some sort of feedback on what might be the problem here?

@markbates care to help out here?

Sorry, for some reason I didn't see this issue before. So there was a bug in rc1 having to do with loading in Rails. Have you tried using version 3.0.1?

Just did and it solves the issue somewhat. I still have to require_relative 'defaults.rb' for the default configuration but it works good enough.