Rails - call to engine_name seems to be ignored -
i want make engine isolated 2 namespaces. is, let example i'd make engine classes live in:
car::bmw and thus, models example should placed in:
app/models/car/bmw/ and tables should prefixed example:
car_bmw_ i tried accomplish having code in lib/car/bmw/engine.rb
module car module bmw class engine < ::rails::engine isolate_namespace car::bmw # call: engine_name 'car_bmw' end end end with code whenever generate model however, model placed in:
app/models/car and table prefixed by:
car_ what doing wrong? version of rails using 4.0.0.beta1
edit
i found method in rails::generators::namedbase
def namespaced_path @namespaced_path ||= namespace.name.split("::").map {|m| m.underscore }[0] end which, can see, takes first part of namespace. know why is?
is bug in rails or not supposed have classes doubly namespaced?
this quick hack resorted to, fix generators.
require 'rails/generators' rails::generators::namedbase.class_eval protected def namespaced_class_path @namespaced_class_path ||= [namespaced_path.split('/')] + @class_path end def namespaced_path @namespaced_path ||= namespace.name.split("::").map {|m| m.underscore }.join('/') end def class_name ([file_name]).map!{ |m| m.camelize }.join('::') end end
using class
module car module bmw class engine < ::rails::engine isolate_namespace car::bmw # call: engine_name 'car_bmw' paths["app/models"] << "app/models/car/bmw" end end end would allow load models subdirectory specified. cannot if going influence generating process, though.
there's whole lot more configuration options, see e.g. here. edit them match needs.
Comments
Post a Comment