Skip to content

Instantly share code, notes, and snippets.

@littlemove
Created October 2, 2012 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save littlemove/3817874 to your computer and use it in GitHub Desktop.
Save littlemove/3817874 to your computer and use it in GitHub Desktop.
irb(main):005:0> Hotel.first
Hotel.first
Hotel Load (58.6ms) SELECT `hotels`.* FROM `hotels` LIMIT 1
EXPLAIN (68.0ms) EXPLAIN SELECT `hotels`.* FROM `hotels` LIMIT 1
EXPLAIN for: SELECT `hotels`.* FROM `hotels` LIMIT 1
+----+-------------+--------+------+---------------+------+---------+------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+--------+------+---------------+------+---------+------+------+-------+
| 1 | SIMPLE | hotels | ALL | NULL | NULL | NULL | NULL | 1 | |
+----+-------------+--------+------+---------------+------+---------+------+------+-------+
1 row in set (0.07 sec)
=> #<Hotel id: 1, name: "Occidental Miramar", created_at: "2012-09-27 14:55:18", updated_at: "2012-09-27 14:58:32">
irb(main):006:0> I18n.locale
I18n.locale
=> :en
irb(main):007:0> I18n.locale = :es
I18n.locale = :es
=> :es
irb(main):008:0> Hotel.first
Hotel.first
Hotel Load (16.4ms) SELECT `hotels`.* FROM `hotels` LIMIT 1
=> #<Hotel id: 1, name: "Occidental Miramar", created_at: "2012-09-27 14:55:18", updated_at: "2012-09-27 14:58:32">
irb(main):009:0> Hotel.first.name
Hotel.first.name
Hotel Load (65.7ms) SELECT `hotels`.* FROM `hotels` LIMIT 1
HotelTranslation Load (60.1ms) SELECT `hotel_translations`.* FROM `hotel_translations` WHERE `hotel_translations`.`hotel_id` = 1 ORDER BY created_at DESC
=> "Occidental Miramar - ES"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment