gem - Can you add more than one local engine to a Rails 3 app? -


i'm trying break several pieces of reusable application functionality rails engines. have no trouble @ getting 1 engine work, app doesn't seem load data subsequent engines. i'm developing multiple engines simultaneously, i'm requiring them testapp's gemfile :path option.

here's (simplified) setup (my understanding of bare minimum setup engine simple model):

my_engines/engine1/lib/engine1.rb:

module engine1 require 'engine' if defined?(rails) && rails::version::major == 3 end 

my_engines/engine1/lib/engine.rb:

require 'engine1' require 'rails'  module engine1 class engine < rails::engine  end end 

my_engines/engine1/app/models/engine1/model1.rb:

module engine1     class model1     end end 

my second engine, engine2 setup identically , in same parent directory (just name engine2 , model model2).

i'm using jeweler package , generate gemspecs both engines, , i'm requiring both engines in test application so:

my_engines/testapp/gemfile:

gem 'engine1', :path => '../engine1' gem 'engine2', :path => '../engine2' 

the weird thing when fire rails console testapp, engine1::model1.new works, engine1::model1.new results in "nameerror: uninitialized constant engine2::model2". seems true models, routes, controllers, etc. include subsequent engines. i've scoured internet no avail. thoughts?

i think i've figured out. in case else out there happens playing rails3 engines (much recommended), , runs issue (hopefully not), problem having engine.rb file , engine_name.rb files both sitting side-by-side in lib dir. solution create engine_name dir within lib , put engine.rb file in there (i guess rails loads first engine.rb file finds in gem or plugin's lib dir). so...

bad (only loads 1 engine.rb in host app):

/some_engine     |-- lib     |-- some_engine.rb     |-- engine.rb  

seems work:

/some_engine     |-- lib     |-- some_engine.rb     |-- some_engine         |-- engine.rb  

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -