Sha256: b642be6ef1f16939ece1722a0e21bd61296a4b97a5a4994aac16251781bf931a

Contents?: true

Size: 576 Bytes

Versions: 31

Compression:

Stored size: 576 Bytes

Contents

module Enjoy::ModelLocalizeable
  extend ActiveSupport::Concern

  module ClassMethods
    def convert2localize
      self.all.to_a.map do |p|
        p.convert2localize
      end
    end
  end

  def convert2localize
    arr = {}
    self.localized_fields.keys.each do |f|
      next if self[f].is_a?(Hash)
      arr[f] = self.remove_attribute(f)
      self[f] = {}
    end
    self.save

    I18n.available_locales.each do |l|
      I18n.with_locale(l) do
        arr.each_pair do |f, v|
          self.send(f + "=", v)
        end
      end
    end
    self.save
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
enjoy_cms-0.4.1 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.4.0.5 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.4.0.4 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.4.0.3 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.4.0.2 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.4.0.1 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.4.0 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.4.0.beta3 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.3.7.4 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.3.7.3 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.3.7.2 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.3.7.1 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.3.7 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.3.6.2 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.3.6.1 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.3.6 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.3.5 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.3.4 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.3.3 app/models/concerns/enjoy/model_localizeable.rb
enjoy_cms-0.3.2.1 app/models/concerns/enjoy/model_localizeable.rb