how to set primary key in rails 2.0.2

in your user model write
set_primary_key "user_id"

Bala kishore Pulicherla wrote:

in your user model write
set_primary_key "user_id"

On Jul 19, 9:22�am, dare ruby <rails-mailing-l...@andreas-s.net>

Dear bala,

Thanks for your suggestion. its working fine now.

Could you please provide details about auto incrementation for above
mentioned primary key.

Thanks in advance

Regards,
Jose Martin

u can put the id as itself as an auto increment and while ur creating the new user make the id to user_id and update.

for ex.
user = User.new(params[:user])
if user.save!
user_id = user.id

user.update_attribute(:user_id,"#{user.id})
respond_to |format| do
ur - stuff
end
end

mean while i’ll find any :auto_increment option is there :frowning:

t.column :user_id, :primary_key, :null => false

hope this will work for u :slight_smile:

ur welcome. :slight_smile: