Hi Guys,

 

First of all great job with an extremely useful plugin infrastructure.

 

Ive been looking at migrating part of some existing code into an engine
within rails 2.3. Essentially trying to modularize some code. We have
different config for different environments and also may end up using
initializers. So far I have managed to get it to work by replicating the
same directory structure in the main rails app and including the
following code in the init.rb file in the plugin.

 

require 'ruby-debug'

 

engine_directory = File.expand_path(File.join(File.dirname(__FILE__)))

 

config.after_initialize do

  Dir[File.join(engine_directory,
"config/initializers/**/*.rb")].sort.each do |engine_initializer|

    initializer.require_or_load(engine_initializer)

  end

 

 

 
engine_environment_path="#{engine_directory}/config/environments/#{confi
g.environment}.rb"

 

  constants = self.class.constants

 

  eval(IO.read(engine_environment_path), binding,
engine_environment_path)

 

  (self.class.constants - constants).each do |const|

    Object.const_set(const, self.class.const_get(const))

  end

 

end

 

Everything seems to work but was wondering what the best
practice/convention was for doing this.

 

Thanks,

Venura

_______________________________________________
Engine-Users mailing list
[email protected]
http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org

Reply via email to