diff options
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/engine.rb | 8 | ||||
-rw-r--r-- | railties/lib/rails/railtie.rb | 7 |
2 files changed, 14 insertions, 1 deletions
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 13629e0de3..663feb4e32 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -201,11 +201,19 @@ module Rails end def namespace(mod) + # TODO: extract that into a module + engine_name(generate_railtie_name(mod)) + _railtie = self + name = engine_name mod.singleton_class.instance_eval do define_method(:_railtie) do _railtie end + + define_method(:table_name_prefix) do + "#{name}_" + end end end end diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb index ab565b0cdc..09650789ac 100644 --- a/railties/lib/rails/railtie.rb +++ b/railties/lib/rails/railtie.rb @@ -167,8 +167,13 @@ module Rails def railtie_name(name = nil) @railtie_name = name.to_s if name - @railtie_name ||= ActiveSupport::Inflector.underscore(self.name).gsub("/", "_") + @railtie_name ||= generate_railtie_name(self.name) end + + protected + def generate_railtie_name(class_or_module) + ActiveSupport::Inflector.underscore(class_or_module).gsub("/", "_") + end end delegate :railtie_name, :to => "self.class" |