Nesting modules inside of a Rails eninge gem

AJ Acevedo
Thu, 02 May 2013 16:16:01 -0000

What is the proper syntax to nest child modules within a parent module that
is being as an isolate_namespace Rails engine gem?

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

For example. The parent module is MyEngine and the child module is Blog.
MyEngine will share common domain, like CRUD, Taggable, Searchable, etc,
which will keep the gem code DRY and isolated from the main app (MyApp)

Are either of the two approaches correct? Any advice?

# A
# lib/myengine/blog.rb
module MyEngine
  module Blog
    # def ...
  end
end

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

--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/3gBcErT2ULUJ.
For more options, visit https://groups.google.com/groups/opt_out.