Last active
December 25, 2015 08:38
-
-
Save indyarocks/6947792 to your computer and use it in GitHub Desktop.
ActiveRecord log in console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> rails c | |
Loading development environment (Rails 4.0.0) | |
2.0.0p247 :001 > ActiveRecord::Base.logger = Logger.new(STDOUT) | |
=> #<Logger:0x007f816e1c35a8 @progname=nil, @level=0, @default_formatter=#<Logger::Formatter:0x007f816e1c3580 @datetime_format=nil>, @formatter=nil, @logdev=#<Logger::LogDevice:0x007f816e1c3530 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:<STDOUT>>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0x007f816e1c3508 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x007f816e1c34b8>>>> | |
2.0.0p247 :002 > user = User.first | |
D, [2013-10-12T14:46:23.337060 #25919] DEBUG -- : User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 | |
=> #<User id: 1, name: "Chandan Kumar", email: "[email protected]", created_at: "2013-09-16 20:01:15", updated_at: "2013-09-16 20:34:20", password_digest: "$2a$10$qoNP6rM.89XSOJEXIsXig.9LKM2jcvY0Y4bFhCECCJ4X...", remember_token: "66302290bbc685a193b5d2ab5c8d3fc67e56318e", admin: true> | |
2.0.0p247 :003 > user.microposts | |
D, [2013-10-12T14:46:28.886696 #25919] DEBUG -- : Micropost Load (36.8ms) SELECT "microposts".* FROM "microposts" WHERE "microposts"."user_id" = ? ORDER BY created_at DESC [["user_id", 1]] | |
=> #<ActiveRecord::Associations::CollectionProxy [#<Micropost id: 301, content: "Cool\r\n", user_id: 1, created_at: "2013-10-06 15:27:10", updated_at: "2013-10-06 15:27:10">, #<Micropost id: 295, content: "Eligendi ducimus aut incidunt vel vitae accusamus.", user_id: 1, created_at: "2013-09-16 20:01:23", updated_at: "2013-09-16 20:01:23">, #<Micropost id: 289, content: "Dolores blanditiis aut omnis corrupti et unde.", user_id: 1, created_at: "2013-09-16 20:01:23", updated_at: "2013-09-16 20:01:23">, #<Micropost id: 283, content: "Quia iste et consequatur et id illo voluptas.", user_id: 1, created_at: "2013-09-16 20:01:23", updated_at: "2013-09-16 20:01:23">, #<Micropost id: 277, content: "Excepturi voluptatem adipisci nesciunt praesentium ...", user_id: 1, created_at: "2013-09-16 20:01:23", updated_at: "2013-09-16 20:01:23">, #<Micropost id: 271, content: "Deserunt et labore explicabo est id voluptatibus vo...", user_id: 1, created_at: "2013-09-16 20:01:23", updated_at: "2013-09-16 20:01:23">, #<Micropost id: 265, content: "Aut perspiciatis sapiente aspernatur maiores.", user_id: 1, created_at: "2013-09-16 20:01:23", updated_at: "2013-09-16 20:01:23">, #<Micropost id: 259, content: "Labore illo accusantium atque asperiores voluptas.", user_id: 1, created_at: "2013-09-16 20:01:23", updated_at: "2013-09-16 20:01:23">, #<Micropost id: 253, content: "Laborum tempora eum ipsa dolores.", user_id: 1, created_at: "2013-09-16 20:01:23", updated_at: "2013-09-16 20:01:23">, #<Micropost id: 247, content: "Excepturi commodi quibusdam velit deserunt nulla om...", user_id: 1, created_at: "2013-09-16 20:01:23", updated_at: "2013-09-16 20:01:23">, ...]> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment