I _think_, though I may be corrected, that when you do create it
allows the database to set the id. If you provide one yourself it is
ignored. The database has allocated the next in sequence even though
earlier ones have been removed.
Hi
So my question is how can I ensure that even after running rake
db:seed (rake db:seed_fu) a number of times my primary key ie, id here,
does not get modified? Should I need to write an update_id function
again?
If you really need the id to be pre-defined (though why you need to do
this I do not know, it is generally a bad idea) then in your seed code
you could check whether a record of that id already exists and if it
does then update it rather than re-creating it.
I dont get what I expected for the id fields. I expect id to be
generated like
1,2,3....
If you really need the id to be pre-defined (though why you need to do
this I do not know, it is generally a bad idea)
Why I need the id to be predefined means suppose at a later stage
if already that id may e saved to a number of tables as foreign key. But
suppose if execute rake db:seed_fu then if the id changed to 5,6,7
instead of 1,2,3
the total solution may be a big fail
So when I checked the way which I mentioned in my first post
accidently I noticed this. Then post a message to a get a clarification
since I dont know where the fault is
I think one more thing to ensure the ids are the values that I
expected is, after creation call a function like