Custom non auto-incrementing ActiveRecord “id” column possible?

Something like this: create_table :blah, {:id => false} do |t| t. Int :my_custom_int_id end execute "ALTER TABLE blah ADD PRIMARY KEY (my_custom_int_id).

This looks like what I was looking for, thanks. – mirthlab Nov 22 '10 at 22:24.

You can manually set the id before you save the model. A = Model. New a.Id = 8888 #from itunes a.

Save However, you should consider a separate field called itunes_id instead of this approach.

I am currently using a separate itunes_id field as you describe. The problem is that the API I'm using returns itunes ids so it's a pain to do an extra lookup for itunes_id -> my model id all the time. – mirthlab Nov 22 '10 at 5:40.

If your company bans the Id column, take it in stride and use whatever naming convention they prefer. Focus on learning things that are ACTUALLY bad practices (such as multiple nested correlated sub queries) rather than mulling over issues like this. The issue of naming your columns "ID" is closer to being a matter of taste than it is to being a bad practice.

A NOTE TO EDITORS : The error in this query is intentional and is being used to make a point. Please read the full answer before editing.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions