diff options
Diffstat (limited to 'activerecord/lib/rails/generators/active_record/model')
-rw-r--r-- | activerecord/lib/rails/generators/active_record/model/model_generator.rb | 5 | ||||
-rw-r--r-- | activerecord/lib/rails/generators/active_record/model/templates/module.rb | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/lib/rails/generators/active_record/model/model_generator.rb b/activerecord/lib/rails/generators/active_record/model/model_generator.rb index 3e72fbeca8..539c2517ee 100644 --- a/activerecord/lib/rails/generators/active_record/model/model_generator.rb +++ b/activerecord/lib/rails/generators/active_record/model/model_generator.rb @@ -20,6 +20,11 @@ module ActiveRecord template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb") end + def create_module_file + return if class_path.empty? + template 'module.rb', File.join('app/models', "#{class_path.join('/')}.rb") + end + hook_for :test_framework protected diff --git a/activerecord/lib/rails/generators/active_record/model/templates/module.rb b/activerecord/lib/rails/generators/active_record/model/templates/module.rb new file mode 100644 index 0000000000..bb4220f038 --- /dev/null +++ b/activerecord/lib/rails/generators/active_record/model/templates/module.rb @@ -0,0 +1,5 @@ +module <%= class_path.map(&:camelize).join('::') %> + def self.table_name_prefix + '<%= class_path.join('_') %>_' + end +end |