I am using rails 3.0.3 with inherited resources and active record sql server adapter and tinyTds gems.
When I try to create an object with a has_one relation, (using create! from Inherited resources) the primary key id does not get set in the parent object. Hence when it tries to insert that uninitialized garbage id as the foreign key in the has_one object, I get an arithmatic overflow error for trying to insert garbage id as integer for the foreign key.
Has anyone faced this problem.
e.g. User has_one Address. (While creating a new user, the User.id does not get updated hence while trying to insert user_id into Address table, the insertion fails and complete transaction is rolled back with the end result that there is no entry in User as well as Address table)
While trying to trace the code, in active record lib/active_record/persistence.rb create method is returning new_id as garbage uninitialized 开发者_C百科value instead of the id of the newly inserted record.
Any help / pointers would be greatly appreciated to help in solving this problem.
Even on rails console, if I do a simple @user = User.create!, the @user object does not have the correct primary key id.
Please consult the manual.
https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Using-TinyTDS
Basically you do not have "tds version" set correctly to 8 in your freetds.conf file.
精彩评论