Sha256: 3e2ac8f9ce4a585723cdeb4721e67f2c48c2a58835b429d29600110fde378da9

Contents?: true

Size: 710 Bytes

Versions: 8

Compression:

Stored size: 710 Bytes

Contents

class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
  def change
<% attributes.each do |attribute| -%>
<% I18n.available_locales.each do |locale| -%>
<% column_name = Mobility.normalize_locale_accessor(attribute.name, locale) -%>
<% if connection.column_exists?(table_name, column_name) -%>
<% warn "#{column_name} already exists, skipping." %>
<% else -%>
    add_column :<%= table_name %>, :<%= column_name %>, :<%= attribute.type %><%= attribute.inject_options %>
    <%- if attribute.has_index? -%>
    add_index  :<%= table_name %>, :<%= column_name %><%= attribute.inject_index_options %>
    <%- end -%>
<% end -%>
<% end -%>
<% end -%>
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mobility-0.1.18 lib/generators/rails/mobility/templates/column_translations.rb
mobility-0.1.17 lib/generators/rails/mobility/templates/column_translations.rb
mobility-0.1.16 lib/generators/rails/mobility/templates/column_translations.rb
mobility-0.1.15 lib/generators/rails/mobility/templates/column_translations.rb
mobility-0.1.14 lib/generators/rails/mobility/templates/column_translations.rb
mobility-0.1.13 lib/generators/rails/mobility/templates/column_translations.rb
mobility-0.1.12 lib/generators/rails/mobility/templates/column_translations.rb
mobility-0.1.11 lib/generators/rails/mobility/templates/column_translations.rb