Advertisement
Guest User

Untitled

a guest
Mar 27th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. $ rails console
  2. >> first_user = User.first
  3. => #<User id: 1, name: "Michael Hartl", email: "michael@example.org",
  4. created_at: "2014-07-21 02:01:31", updated_at: "2014-07-21 02:01:31">
  5. >> first_user.microposts
  6. => [#<Micropost id: 1, content: "First micropost!", user_id: 1, created_at:
  7. "2014-07-21 02:37:37", updated_at: "2014-07-21 02:37:37">, #<Micropost id: 2,
  8. content: "Second micropost", user_id: 1, created_at: "2014-07-21 02:38:54",
  9. updated_at: "2014-07-21 02:38:54">]
  10. >> micropost = first_user.microposts.first # Micropost.first would also work.
  11. => #<Micropost id: 1, content: "First micropost!", user_id: 1, created_at:
  12. "2014-07-21 02:37:37", updated_at: "2014-07-21 02:37:37">
  13. >> micropost.user
  14. => #<User id: 1, name: "Michael Hartl", email: "michael@example.org",
  15. created_at: "2014-07-21 02:01:31", updated_at: "2014-07-21 02:01:31">
  16. >> exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement