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

Remove an empty line from generated migration

Currently, if you run `rails g migration remove_column_from_models`,
there is an empty line before `remove_column` line because we forgot to
use `-%>` in the template:

    $ bin/rails g migration remove_title_from_posts title:string
          invoke  active_record
          create    db/migrate/20200114061235_remove_title_from_posts.rb

    $ cat db/migrate/20200114061235_remove_title_from_posts.rb
    class RemoveTitleFromPosts < ActiveRecord::Migration[6.1]
      def change

        remove_column :posts, :title, :string
      end
    end

This commit adds the missing `-` in front of `-%>` to make it removes
the empty line.
This commit is contained in:
Prem Sichanugrist 2020-01-14 15:17:46 +09:00
parent 5371d5dcf2
commit 0ac7b8c843

View file

@ -37,7 +37,7 @@ class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Mi
<%- if attribute.has_index? -%>
remove_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
<%- end -%>
<%- if !attribute.virtual? %>
<%- if !attribute.virtual? -%>
remove_column :<%= table_name %>, :<%= attribute.name %>, :<%= attribute.type %><%= attribute.inject_options %>
<%- end -%>
<%- end -%>