Set_primary_key issue


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?