diff options
Diffstat (limited to 'activerecord/lib/rails')
-rw-r--r-- | activerecord/lib/rails/generators/active_record/migration/templates/migration.rb | 18 | ||||
-rw-r--r-- | activerecord/lib/rails/generators/active_record/model/model_generator.rb | 2 |
2 files changed, 13 insertions, 7 deletions
diff --git a/activerecord/lib/rails/generators/active_record/migration/templates/migration.rb b/activerecord/lib/rails/generators/active_record/migration/templates/migration.rb index bbb7c53d86..8ac21c1410 100644 --- a/activerecord/lib/rails/generators/active_record/migration/templates/migration.rb +++ b/activerecord/lib/rails/generators/active_record/migration/templates/migration.rb @@ -1,11 +1,17 @@ class <%= migration_class_name %> < ActiveRecord::Migration - def self.up<% attributes.each do |attribute| %> - <%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type %><% end -%> - <%- end %> + def self.up +<% attributes.each do |attribute| -%> + <%- if migration_action -%> + <%= migration_action %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'add' %>, :<%= attribute.type %><% end %> + <%- end -%> +<%- end -%> end - def self.down<% attributes.reverse.each do |attribute| %> - <%= migration_action == 'add' ? 'remove' : 'add' %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'remove' %>, :<%= attribute.type %><% end -%> - <%- end %> + def self.down +<% attributes.reverse.each do |attribute| -%> + <%- if migration_action -%> + <%= migration_action == 'add' ? 'remove' : 'add' %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'remove' %>, :<%= attribute.type %><% end %> + <%- end -%> +<%- end -%> end end 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 539c2517ee..960c29c49c 100644 --- a/activerecord/lib/rails/generators/active_record/model/model_generator.rb +++ b/activerecord/lib/rails/generators/active_record/model/model_generator.rb @@ -22,7 +22,7 @@ module ActiveRecord def create_module_file return if class_path.empty? - template 'module.rb', File.join('app/models', "#{class_path.join('/')}.rb") + template 'module.rb', File.join('app/models', "#{class_path.join('/')}.rb") if behavior == :invoke end hook_for :test_framework |