translatable_ar 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/templates/text.rb +16 -2
  2. metadata +1 -1
@@ -14,7 +14,7 @@ class SetupTranslatableAr < ActiveRecord::Migration
14
14
  if object[:<%=attribute%>].is_a? Hash
15
15
  object.<%=attribute%>_i18n_temp = object[:<%=attribute%>]
16
16
  else
17
- object.<%=attribute%>_i18n_temp = {'<%= I18n.locale%>' => object[:<%=attribute%>]}
17
+ object.<%=attribute%>_i18n_temp = {'<%= I18n.default_locale%>' => object[:<%=attribute%>]}
18
18
  end
19
19
  <% end -%>
20
20
  object.save if object.changed?
@@ -31,9 +31,23 @@ class SetupTranslatableAr < ActiveRecord::Migration
31
31
  def down
32
32
  <% TranslatableAR.models.each do |model| -%>
33
33
  <% model.translatable_ar_attributes.each do |attribute| -%>
34
- change_column :<%= model.table_name %>, :<%= attribute %>, :<%= model.columns_hash[attribute.to_s].type %>
34
+ add_column :<%= model.table_name %>, :<%= attribute %>_i18n_temp, :<%= model.columns_hash[attribute.to_s].type %>
35
35
  <% end -%>
36
36
  <% end -%>
37
+ <% TranslatableAR.models.each do |model| -%>
38
+
39
+ <%= model.to_s %>.all.each do |object|
40
+ <% model.translatable_ar_attributes.each do |attribute| -%>
41
+ object.<%=attribute%>_i18n_temp = object[:<%=attribute%>]['<%= I18n.default_locale%>']
42
+ <% end -%>
43
+ object.save if object.changed?
44
+ <% end -%>
45
+ <% TranslatableAR.models.each do |model| -%>
46
+ <% model.translatable_ar_attributes.each do |attribute| -%>
47
+ remove_column :<%= model.table_name %>, :<%= attribute %>
48
+ rename_column :<%= model.table_name %>, :<%= attribute%>_i18n_temp, :<%= attribute %>
49
+ <% end -%>
50
+ <% end -%>
37
51
  end
38
52
 
39
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translatable_ar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: