IRB hex values

Hi all,

Im working on a copy contact info into project method. Nosing aroundwith
IRB I
see a hex value. Named Contact:0x40ca01cc

#<Contact:0x40ca01cc @attributes={“name”=>“GP-net”, “id”=>“7”,
“lastname”=>“Petersen”, “firstname”=>“Gerard”}>

Why is it there like that and not in a human readable way?

– Method:

@project = Project.new
@project_contact = ProjectContact.new

@contacts_list = Contact.find_by_sql(‘select t1.name, t2.firstname,
t2.lastname, t2.id from companies AS t1, contacts AS t2 where t1.id =
t2.company_id order by t1.name’)

@project_contacts = @contacts_list.collect { |c| [ c.name + " - " +
c.firstname + " " + c.lastname, c.id ] }

render_action ‘edit_project’

– Models:

class Project < ActiveRecord::Base
has_one :project_contact
has_many :project_products
end
class ProjectContact < ActiveRecord::Base
belongs_to :project
end
class ProjectProduct < ActiveRecord::Base
belongs_to :project
end

“Who cares if it doesn’t do anything? It was made with our new
Triple-Iso-Bifurcated-Krypton-Gate-MOS process …”

My $Grtz =~ Gerard;
~
:wq!

Gerard wrote:

Hi all,

Im working on a copy contact info into project method. Nosing aroundwith IRB I
see a hex value. Named Contact:0x40ca01cc

#<Contact:0x40ca01cc @attributes={“name”=>“GP-net”, “id”=>“7”,
“lastname”=>“Petersen”, “firstname”=>“Gerard”}>

Why is it there like that and not in a human readable way?

That is the human readable way :slight_smile: It’s Ruby’s internal ID for that
specific Contact instance, rather than anything related to the database.
if you did another Contact.find(7), you’d get the same DB info, but
that hex number would be different.

I don’t know how it’s implemented internally, but I wouldn’t be
surprised if it was a hash key, or an address lookup of some form.

Alex,

Thanx. I just thought I was asking my app the wrong questions.

Regards,

Gerard.

On Friday 06 January 2006 13:20, Alex Y. tried to type something
like:

That is the human readable way :slight_smile: It’s Ruby’s internal ID for that
specific Contact instance, rather than anything related to the database.
if you did another Contact.find(7), you’d get the same DB info, but
that hex number would be different.

I don’t know how it’s implemented internally, but I wouldn’t be
surprised if it was a hash key, or an address lookup of some form.


“Who cares if it doesn’t do anything? It was made with our new
Triple-Iso-Bifurcated-Krypton-Gate-MOS process …”

My $Grtz =~ Gerard;
~
:wq!