cbrulak
cbrulak

Reputation: 15629

ruby-on-rails: getting database unique id

I have a simple model, Post with title and content.

I'm trying to link Post & Users together by the post unique_id and the user unique_id

In the course of my testing I've noticed that object_id is not the unique id of the record in the database. It changes with every page refresh.

My schema does not explicitly state the need for a unique id since I thought that attribute was automatically generated.

So, should i change my schema to have a unique id or can I access it through another method?

Upvotes: 0

Views: 409

Answers (1)

Anonymous
Anonymous

Reputation:

Is this a trick question? You have post.id and user.id (Don't use post.object_id - maybe you were confused by that.)

Upvotes: 1

Related Questions