Sha256: dbf940c76bdc6ff7063b870f6f4ba97dcd48a3db7fd0643b71000bb5aaf0148f

Contents?: true

Size: 607 Bytes

Versions: 63

Compression:

Stored size: 607 Bytes

Contents

class AddI18nFields<%= file_hash.capitalize %> < ActiveRecord::Migration
  def change
<% tables.each do |table, columns| -%>
<% columns.each do |column| -%>
<% languages.each do |language| -%>
<% klass = table.singularize.camelize.constantize -%>
<% unless klass.column_names.include?("#{column}_#{language}") -%>
<% if klass.columns_hash[column.to_s] -%>
    add_column :<%= table.gsub('/', '_') %>, :<%= column %>_<%= language %>, :<%= klass.columns_hash[column.to_s].type %>
<% else -%>
<% puts "Table #{table} has no column #{column}" -%>
<% end -%>
<% end -%>
<% end -%>
<% end -%>
<% end -%>
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
tenon-1.1.8 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.1.7 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.1.6 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-2.1.0 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-2.0.8 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-2.0.7 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-2.0.6 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-2.0.5 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-2.0.4 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-2.0.3 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-2.0.2 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-2.0.1 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-2.0.0 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.1.5 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.1.4 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.1.3 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.1.2 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.1.1 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.76 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.75 lib/generators/tenon/i18n_migrations/templates/migration.rb