Sha256: 824d0f6f4cb0f593c528fba68da40a09a100568d82a5249b0f4e3f2f941ad0ea

Contents?: true

Size: 692 Bytes

Versions: 10

Compression:

Stored size: 692 Bytes

Contents

require './helper'
require 'mongomapper_ext/types/translation'

class TranslationEx
  include MongoMapper::Document

  key :title, Translation, :default => Translation.build({"es" => "titulo", "en" => "title"}, "en")
  key :body, Translation, :default => Translation.build({"es" => "contenido", "en" => "content"}, "en")
end

TranslationEx.delete_all
o1 = TranslationEx.create
o2 = TranslationEx.create


o1.title = "my new title"
puts o1.title[:es]

o1.title[:es] = "mi nuevo titulo"
o1.save

puts "languages: #{o1.title.languages.inspect}"
puts "default text: #{o1.title}"

o1 = TranslationEx.find(o1.id)
o2 = TranslationEx.find(o2.id)

puts o1.to_mongo.inspect


TranslationEx.delete_all

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mongomapper_ext-0.5.2 examples/i18n.rb
mongomapper_ext-0.5.1 examples/i18n.rb
mongomapper_ext-0.5.0 examples/i18n.rb
mongomapper_ext-0.4.0 examples/i18n.rb
mongomapper_ext-0.3.0 examples/i18n.rb
mongomapper_ext-0.2.4 examples/i18n.rb
mongomapper_ext-0.2.3 examples/i18n.rb
mongomapper_ext-0.2.2 examples/i18n.rb
mongomapper_ext-0.2.1 examples/i18n.rb
mongomapper_ext-0.2.0 examples/i18n.rb