1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Line break in migration template and nicer code indentation

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Łukasz Strzałkowski 2010-06-25 10:51:43 +02:00 committed by José Valim
parent b01df28413
commit 518b16d9ae

View file

@ -1,15 +1,17 @@
class <%= migration_class_name %> < ActiveRecord::Migration
def self.up<% attributes.each do |attribute| %>
<%- if migration_action -%>
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 -%>
end
def self.down<% attributes.reverse.each do |attribute| %>
<%- if migration_action -%>
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
end