Skip to content

Instantly share code, notes, and snippets.

@danbeaulieu
Created November 4, 2012 03:57
Show Gist options
  • Save danbeaulieu/4010100 to your computer and use it in GitHub Desktop.
Save danbeaulieu/4010100 to your computer and use it in GitHub Desktop.
Loading development environment (Rails 3.2.6)
1.9.3p194 :001 > I18n.locale
=> :es
1.9.3p194 :002 > I18n.locale = :en
=> :en
1.9.3p194 :005 > p = Product.find(27)
Product Load (0.8ms) SELECT "products".* FROM "products" WHERE "products"."id" = $1 LIMIT 1 [["id", 27]]
=> #<Product id: 27, min_capacity: 2, max_capacity: 10, start_time: "2000-01-01 22:18:00", languages: "English, Spanish", tour_operator_id: 4, created_at: "2012-10-19 22:20:53", updated_at: "2012-10-31 16:06:05", location: "Santiago", duration: #<BigDecimal:5267690,'0.8E1',9(18)>, price_in_local_units: 120000, internal_name: "Dans Climbing Trip", min_api_reservation_hours: 10>
1.9.3p194 :006 > p.translations
Product::Translation Load (0.9ms) SELECT "product_translations".* FROM "product_translations" WHERE "product_translations"."product_id" = 27
=> [#<Product::Translation id: 46, product_id: 27, locale: "es", name: "Dans Climbing Trip ES", description: "This is a climbing trip", difficulty: "V3", meeting_point: "Centro", what_to_bring: "Food", whats_included: "Harness, shoes", created_at: "2012-10-19 22:20:53", updated_at: "2012-11-04 03:42:43">]
1.9.3p194 :007 > p.save
(0.3ms) BEGIN
ProductTranslation Load (0.8ms) SELECT "product_translations".* FROM "product_translations" WHERE "product_translations"."product_id" = 27
Product::Translation Load (0.7ms) SELECT "product_translations".* FROM "product_translations" WHERE "product_translations"."product_id" = 27 AND "product_translations"."locale" = 'en' LIMIT 1
SQL (2.7ms) INSERT INTO "product_translations" ("created_at", "description", "difficulty", "locale", "meeting_point", "name", "product_id", "updated_at", "what_to_bring", "whats_included") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING "id" [["created_at", Sun, 04 Nov 2012 03:49:21 UTC +00:00], ["description", nil], ["difficulty", nil], ["locale", "en"], ["meeting_point", nil], ["name", nil], ["product_id", 27], ["updated_at", Sun, 04 Nov 2012 03:49:21 UTC +00:00], ["what_to_bring", nil], ["whats_included", nil]]
Product::Translation Load (0.4ms) SELECT "product_translations".* FROM "product_translations" WHERE "product_translations"."id" = $1 LIMIT 1 [["id", 46]]
Product::Translation Load (0.2ms) SELECT "product_translations".* FROM "product_translations" WHERE "product_translations"."id" = $1 LIMIT 1 [["id", 90]]
(0.6ms) COMMIT
=> true
1.9.3p194 :008 > p.translations
=> [#<Product::Translation id: 46, product_id: 27, locale: "es", name: "Dans Climbing Trip ES", description: "This is a climbing trip", difficulty: "V3", meeting_point: "Centro", what_to_bring: "Food", whats_included: "Harness, shoes", created_at: "2012-10-19 22:20:53", updated_at: "2012-11-04 03:42:43">, #<Product::Translation id: 90, product_id: 27, locale: "en", name: nil, description: nil, difficulty: nil, meeting_point: nil, what_to_bring: nil, whats_included: nil, created_at: "2012-11-04 03:49:21", updated_at: "2012-11-04 03:49:21">]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment