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 4077840
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:36:02+00:00 2026-05-20T17:36:02+00:00

Possible Duplicate: Rails primary key and object id I am baffled as to why

  • 0

Possible Duplicate:
Rails primary key and object id

I am baffled as to why I cannot refer an object’s attributes; hope someone can help…

I need to build a hash that will associate Marker.marker_name with it’s id from the database, which are already stored (the record id will serve as a foreign key in another table).

So, first I retrieve the Marker record via this named scope:

class Marker < ActiveRecord::Base    
named_scope :by_name, lambda { |marker_name| 
    {:conditions => ["marker_name = ?", marker_name]}}

which is called from my Uploads model, like this (marker_name has the value “Amelogenin”):

this_marker = Marker.by_name(marker_name)

I know this worked, because when I Use the debugger, I can see what is in this_marker, which looks like:

(rdb:2) y this_marker

  • !ruby/object:Marker attributes:
    created_at: 2011-03-14 22:21:27.244885
    updated_at: 2011-03-14 22:21:27.244885
    id: “11”
    marker_name: Amelogenin attributes_cache: {}

Yet, I cannot assign the record id in my hash, like this:

$markers[marker_name] = this_marker.id

I cannot seem to refer directly to the id in this way; because, even in the debugger, I get this error:

(rdb:2) p this_marker.id
(__DELEGATION__):2: warning: Object#id will be deprecated; use Object#object_id

Is there some kind of different Ruby syntax I need to be using or what? How can I associate the marker_name with its record id?

Thanks in advance….

  • 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-20T17:36:03+00:00Added an answer on May 20, 2026 at 5:36 pm

    This Marker.by_name(marker_name) returns an array of makers. You should write:

    this_marker = Marker.by_name(marker_name).first
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Rails primary key and object id Very quick question. My server is
Possible Duplicate: Rails primary key and object id On my local development rails environment,
Possible Duplicate: Ruby 1.9.2 and Rails 3 cannot open rails console I have already
Possible Duplicate: how to check if my array includes an object - rails I
Possible Duplicate: Can't convert String into integer in ruby/ruby-on-rails I'm running through a tutorial
Possible Duplicate: Difference between -%> and %> in rails I need to know what
Possible Duplicate: Rails - Help understanding how to use :dependent => :destroy I have
Possible Duplicate: Ruby on Rails: How can i join with a derived table? posts
Possible Duplicate: Best way to use html5 data attributes with rails content_tag helper? How
Possible Duplicate: Rails 2.3-style plugins and deprecation warnings running task in Heroku I am

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.