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.0.53 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.52 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.51 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.50 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.49 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.48 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.47 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.46 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.45 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.44 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.43 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.42 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.41 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.40 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.39 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.38 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.37 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.36 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.35 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.33 lib/generators/tenon/i18n_migrations/templates/migration.rb