ruby on rails - updating wrong value to database -
I'm just trying to increase the record starting in 1 in 2000, when a new record is created On click. Functions to create a record:
If resource_model == student then @ource.testing_id = id + 2000 end
So if the record has an ID of 1, then I think That would be test_id 2001. But instead 2147483647 (maximum mysql limit?)
How to find out if there is any suggestion? Thank you.
-
You can not find the record id while creating the id after the recording of the database Knows.
-
You can not relay the id to give values like 1, 2, 3 ... and so on.
You can get the next testing_id
by something like this:
if resource_model == student then @ Resource.testing_id = Student.first (: order = & gt; "Test_id DESC"). Test_id + 1 end
But if two processes get the same value at the same time, then you will have a duplicate test_id
Comments
Post a Comment