In my database the id for a field is 810. RoR thinks that it is 809.
My log file (below) shows that just before the insert it grabs the next
sequence value. I dont think it should do that. This causes problems
further down the line when trying to access the Person object.
Development Log file :
"SQL (0.016000) select people_seq.nextval id from dual
This is what i have done to solve it, but it is totally wrong/stupid:
Notice “@person.id+=1”
This makes me feel dirty!! anyone any ideas wtf is going on?
Which DB are you using, and why do you think the database has a
different idea about the value of an ID to Rails?
I´ve done some tests with Oracle and it worked perfectly well. I did
only a small trick to avoid getting that decimal point on the ID: on
the view we use :id => doc.id.round.
Do you have a trigger on the table that also fetches the ID from the
sequence when you’re inserting records? If so, you might want to
modify the trigger so that if the new ID is passed in, to use it,
otherwise grab a value from the sequence, something like:
create or modify trigger mytable_bi
before insert on mytable
for each row
if :new.id is null then
insert into mytable values (myseq.nextval, …)
else
insert into mytable values (:new.id, …)
endif
end