I want to write a gem that adds a app/services
directory to a Rails application.
Since I want to add it from within the Gem i came up with this solution:
class Railtie < ::Rails::Railtie
config.after_initialize do |app|
::Rails.logger.info "adding #{ActiveService::Configuration.path} to autoload_path"
app.config.autoload_paths = [ActiveService::Configuration.path] + app.config.autoload_paths
end
end
The problem is that config.autoload_path
is a frozen array, so that modifing it seems not to be a good idea.
Any suggestions of how this could be achieved in a better way?
app.config
is different from the config that is used within the engine class. i am currently stuck with using the railtiebefore_configuration
hook, which can set the autoload_paths array, but runs before all other initializers. so i need to put any configuration into a yml file. – Scent