Skip to content

Instantly share code, notes, and snippets.

@parndt
Created December 19, 2012 23:13
Show Gist options
  • Save parndt/4341490 to your computer and use it in GitHub Desktop.
Save parndt/4341490 to your computer and use it in GitHub Desktop.
My troubles with Globalize3
1.9.3p327 :001 > p=Refinery::Page.first
Refinery::Page Load (0.3ms) SELECT "refinery_pages".* FROM "refinery_pages" LIMIT 1
Refinery::Page::Translation Load (0.2ms) SELECT "refinery_page_translations".* FROM "refinery_page_translations" WHERE "refinery_page_translations"."refinery_page_id" = 1
=> #<Refinery::Page id: 1, parent_id: nil, path: nil, slug: "home", show_in_menu: true, link_url: "/", menu_match: "^/$", deletable: false, draft: false, skip_to_first_child: false, lft: 1, rgt: 14, depth: 0, view_template: nil, layout_template: nil, created_at: "2012-12-19 21:18:13", updated_at: "2012-12-19 21:18:13">
1.9.3p327 :002 > p.translations
=> [#<Refinery::Page::Translation id: 1, refinery_page_id: 1, locale: "en", title: "Home", custom_slug: nil, menu_title: nil, slug: "home", created_at: "2012-12-19 21:18:13", updated_at: "2012-12-19 21:18:13">]
1.9.3p327 :003 > p.title
=> "Home"
1.9.3p327 :004 > p.translations
=> [#<Refinery::Page::Translation id: 1, refinery_page_id: 1, locale: "en", title: "Home", custom_slug: nil, menu_title: nil, slug: "home", created_at: "2012-12-19 21:18:13", updated_at: "2012-12-19 21:18:13">]
1.9.3p327 :005 > Globalize.with_locale(:fr){ p.translations}
=> [#<Refinery::Page::Translation id: 1, refinery_page_id: 1, locale: "en", title: "Home", custom_slug: nil, menu_title: nil, slug: "home", created_at: "2012-12-19 21:18:13", updated_at: "2012-12-19 21:18:13">]
1.9.3p327 :006 > Globalize.with_locale(:fr){ p.title }
Refinery::Page::Translation Load (0.2ms) SELECT "refinery_page_translations".* FROM "refinery_page_translations" WHERE "refinery_page_translations"."refinery_page_id" = 1 AND "refinery_page_translations"."locale" = 'fr' LIMIT 1
=> "Home"
1.9.3p327 :007 > p.translations
=> [#<Refinery::Page::Translation id: 1, refinery_page_id: 1, locale: "en", title: "Home", custom_slug: nil, menu_title: nil, slug: "home", created_at: "2012-12-19 21:18:13", updated_at: "2012-12-19 21:18:13">, #<Refinery::Page::Translation id: nil, refinery_page_id: 1, locale: "fr", title: nil, custom_slug: nil, menu_title: nil, slug: nil, created_at: nil, updated_at: nil>]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment