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.32 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.31 lib/generators/tenon/i18n_migrations/templates/migration.rb
tenon-1.0.30 lib/generators/tenon/i18n_migrations/templates/migration.rb