Forum: Ruby on Rails set_primary_key issue

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
D09c22de4147ca67501550f9d0b8f5d9?d=identicon&s=25 Jefflin (Guest)
on 2007-04-17 06:52
(Received via mailing list)

I am new to the ruby and rails. What I am tried to do is to create a
scaffold based on an existing table in a MS SQL Server database.

Before I used the set_primary_key method, edit and show does not work
in the generated code. Rails displayed the list of the records ok, but
can not determine the id for each record. Create a new record does
work properly,  however.

After I used the set_primary_key method to set the right primary key
(Uesr_ID), rails can now determine the id for each records when list
of the records is displayed. But update does not work properly.
looking at the development log, the update sql statement generated
included all fields except the primary key field under Set cause.
Creating a new record, also generated similar sql insert statement.
The primary key is not included. BTW, for new record function to work,
I have to modify the controller's new method to initialise the id
field, otherwise I will receive "undefined method
`UserID_before_type_cast' " exception.

Look back to the development log, before the set_primary_key method is
used, generated insert statement for the new record does include all

To me, it seems that the activerecord has excluded the primary key
field when generating update and insert statement when the
set_primary_key method is used.

Can anyone point me to the right direction to resolve this issue?

This topic is locked and can not be replied to.