I'm pretty new to Ruby (though not to programming) and am trying to create a persistent config. Though I thought using Configatron would automatically make my config persistent, it does not seem to be the case. How would I make this persistent throughout multiple runs? Should I store this to a file? If so, how? I would think a ~/.myapp
file might be good?

- 755
- 1
- 5
- 27
1 Answers
Persistence in Rails
If you're using Ruby on Rails, you need to modify your initializers for this gem:
app/config/configatron/defaults.rb
app/config/configatron/{development,test,production}.rb
Persistence Without Rails
Ruby Modules
If you're using Ruby itself, rather than the Rails framework, then you need to persist your configuration as a Ruby module (e.g. require "my_configuration"
) or serialize the Configatron class if it can serialized. It looks like the goal of the gem is to avoid serialization, so requiring a module that contains your configuration as executable code seems to be the canonical approach for this gem.
Serialization
I don't use this gem myself, so you'll have to experiment with serializers to see if they work for your use case. For serialization, I'd recommend using one of:
However, if you're using serialization to save and load your configuration, I'm not entirely sure why you'd need this gem in the first place. Your mileage may certainly vary.

- 81,402
- 15
- 141
- 199