0

I'm building a namespaced Rails Engine gem which will be extendable through additional gems. For example: MyEngine is the main gem which will also be the namespace. MyEngine-blog & MyEngine-support are optional gems to extend the MyEngine gem while inheriting the MyEngine namespace.

MyEngine-blog & MyEngine-support are dependent on MyEngine for core functionality and both gems will include spec.add_dependency "synculus" in their gemspec files.

What is the proper way to specify the Rails::Engine for the dependency gems? Do I have to specify class Engine < ::Rails::Engine in each of the MyEngine-blog & MyEngine-support gem's engine.rb files?

# lib/myengine/engine.rb
module MyEngine
  class Engine < ::Rails::Engine
    isolate_namespace MyEngine
  end
end

# lib/myengine/blog/engine.rb
module MyEngine
  class Engine < ::Rails::Engine
    isolate_namespace MyEngine
    module Blog
    end
  end
end

# lib/myengine/support/engine.rb
module MyEngine
  class Engine < ::Rails::Engine
    isolate_namespace MyEngine
    module Support
    end
  end
end
tshepang
  • 12,111
  • 21
  • 91
  • 136
AJ.
  • 1,248
  • 10
  • 27

1 Answers1

1

Take a look at the way spree commerce is doing this with their 2.x release, they have a really great grasp on rails engines.

Spree Commerce 2.x engine.rb

mbarnard
  • 151
  • 7