Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ rails console
- >> first_user = User.first
- => #<User id: 1, name: "Michael Hartl", email: "michael@example.org",
- created_at: "2014-07-21 02:01:31", updated_at: "2014-07-21 02:01:31">
- >> first_user.microposts
- => [#<Micropost id: 1, content: "First micropost!", user_id: 1, created_at:
- "2014-07-21 02:37:37", updated_at: "2014-07-21 02:37:37">, #<Micropost id: 2,
- content: "Second micropost", user_id: 1, created_at: "2014-07-21 02:38:54",
- updated_at: "2014-07-21 02:38:54">]
- >> micropost = first_user.microposts.first # Micropost.first would also work.
- => #<Micropost id: 1, content: "First micropost!", user_id: 1, created_at:
- "2014-07-21 02:37:37", updated_at: "2014-07-21 02:37:37">
- >> micropost.user
- => #<User id: 1, name: "Michael Hartl", email: "michael@example.org",
- created_at: "2014-07-21 02:01:31", updated_at: "2014-07-21 02:01:31">
- >> exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement