I want to make an Engine that is isolated by two namespaces. That is, let say for example I'd like to make an Engine whose classes all live in:
Car::BMW
And thus, my models for example should be placed in:
app/models/car/bmw/
And my tables should be prefixed by for example:
car_bmw_
I tried to accomplish this by having this code in lib/car/bmw/engine.rb
module Car module BMW class Engine < ::Rails::Engine isolate_namespace Car::BMW # This will call: engine_name 'car_bmw' end end end
With this code whenever I generate a model however, the model is placed in:
app/models/car And the table is prefixed by:
car_
The reason for this can be found in Rails::Generators::NamedBase.namespaced_path:
def namespaced_path @namespaced_path ||= namespace.name.split("::").map {|m| m.underscore }[0] end
Which, as you can see, takes only the first part of the namespace. Does anyone know why this is? Am I not supposed to doubly namespace models and controllers or is this a bug?