Model.create ignores id attribute


#1

Hello all,

I’m inserting records from another system and it looks something like
this:

Model.create :id=>123, :name=>“asdf”

I noticed that the id attribute is ignored (the database will
automatically assign an auto_increment id starting from 1).

I remember reading about this before: iirc this is done so that you can
easily fill in model information from forms, but I can’t find any
documentation on this now.

Is there a way to force the id? Or do I have to do:

m = Model.new( :name=>“asdf” )
m.id = 123
m.save

Thanks.


#2

Anthony Lodi wrote:

Hello all,

I’m inserting records from another system and it looks something like
this:

I’d suggest you leave id as an auto-increment and create a new field
(oldsystem_id or something).

Alan