Reputation: 4198
Rails handle table id's automatically, in an incremental way. What if I want to stop this incremental behavior? I am actually building a website that uses the FB API and I d like to set the user id to be the facebook id. I am new to rails, so is that possible?
Upvotes: 1
Views: 162
Reputation: 2299
In your migrations file, have something like this:
create_table :users, {:id => false} do |t|
t.integer :facebook_id
end
and in your model class
Rails 3
class User < ActiveRecord::Base
set_primary_key :facebook_id
end
Rails 4
class User < ActiveRecord::Base
self.primary_key = :facebook_id
end
Upvotes: 0
Reputation: 999
I think its possible, but i would just add another column into your table (in the migration file) with the facebook id.
Upvotes: 1