activerecord - Can you get database id from an object's object_id in Rails? -
here's problem: have rails project 2 models, people , credits, , person has many credits. have access front-end. don't have access source code, console, or database, can see list of people , list of credits.
the table of people looks like: 1 | john | doe id, first, , last name columns.
the credits table looks like: 1 | #<person:0x0000000591aaa0>, credit id , active record object id (right?) person belongs to.
is there anyway database id object id person?
simple answer: no can't, sorry.
slightly fuller answer:
the database id , object id entirely unrelated.
an object_id reference ruby makes particular instance - ie object. whereas id value primary-key of single row of database table.
to illustrate problem: instantiate 5 objects of class person - each of has same data first row of people table, , each object have own object_id have same value database id.
thus - sadly can't use object_id reference id
Comments
Post a Comment