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.74 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.73 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.72 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.71 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.70 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.69 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.68 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.67 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.66 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.65 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.64 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.63 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.62 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.61 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.60 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.59 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.57 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.56 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.55 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.54 lib/generators/tenon/i18n_migrations/templates/migration.rb