Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3244464
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:33:16+00:00 2026-05-17T18:33:16+00:00

I’m going through Ruby on Rails Up and Running by O’Reilly and have run

  • 0

I’m going through Ruby on Rails Up and Running by O’Reilly and have run into a question that I’m not sure where to go to for help.

I’m at the part in the book where I’m creating new objects from the console and then saving them to the database. I’ve already created the database (MySQL), run the migration and finally verified that rails created the database schema (also have gone through the rest of the book to this point).

To create the object I ran the following commands:

ruby script/console

photo = Photo.new

The output that the book showed is:

#<Photo:0x35301d8 @attributes={"filename"=>""}, @new_record=true>

However, the output that I got was:

#<Photo id: nil, filename: nil>

From what I understand, when a new object is created in this manner a unique ID is generated to identify that object but it appears that in my case no unique id was generated. I’ve done quite a bit of googling on this and it’s a difficult thing to search for because it’s not an error message per-se; but I’m pretty sure something has gone wrong. So I thought I’d come to the stackoverflow community for help.

Thanks,
Adam

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:33:16+00:00Added an answer on May 17, 2026 at 6:33 pm

    If you’re talking about the 0x35301d8 part: That unique id is always “generated” (actually it’s the memory address of the object, so generated isn’t the right word, but that doesn’t matter). However ActiveRecord defines it’s own inspect method which gives a bit more readable output and simply does not show the id.

    You can still query the id by calling photo.object_id.

    The reason that the id is displayed in the article is probably that the article uses an older version of rails, where ActiveRecord did not yet define this version of the inspect method.

    The id: nil that’s displayed in your version, is about a different id. That’s the database id your ActiveRecord object has, and it won’t be generated until you save your object to the db.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.