aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorSteve Abatangle <sabat@area51.org>2010-06-11 13:15:14 -0700
committerJosé Valim <jose.valim@gmail.com>2010-06-20 12:32:51 +0200
commit451594784552bd6955687d8ff617c484ec26946b (patch)
tree9c4a29276b2d42381424e05d4ab8fc8fad28e637 /activerecord
parentf9abbf9a4d61fc4b9c2bcd178b548ebbdf7cdb76 (diff)
downloadrails-451594784552bd6955687d8ff617c484ec26946b.tar.gz
rails-451594784552bd6955687d8ff617c484ec26946b.tar.bz2
rails-451594784552bd6955687d8ff617c484ec26946b.zip
Fix problem with migrations template that can cause bogus code to be created
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/rails/generators/active_record/migration/templates/migration.rb12
1 files changed, 8 insertions, 4 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..d6ab3257a0 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,15 @@
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 %>
+ <%- 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 %>
+ <%- if migration_action -%>
+ <%= migration_action == 'add' ? 'remove' : 'add' %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'remove' %>, :<%= attribute.type %><% end %>
+ <%- end -%>
+ <%- end -%>
end
end