I am writing a test outside of a Rails project, but ‘require’-ing enough
to use the ActiveRecord classes. It is connected to SQL Server 2005.
It reads in XML and adds an ActiveRecord object like this :
report = DvrStatusReport.new
:
report.x = y
:
report.save
puts report.id
This outputs a new id each time, but the record doesn’t appear in the
the table according to the SQL Server Management Console.
If I do similar in IRB, it does appear. Using the SQL Server profiler I
see
the line “IF @@TRANCOUNT > 0 COMMIT TRAN” for IRB, but not my test. If I
add
“report.connection.commit_db_transaction()” after report.save the record
does appear.
Although I never ask for transactions, it is turning on
“implicit_transactions” in SQLServer (in my test and IRB), but somehow
the commit is never happening.
Thanks for any assistance.
Regards,
Gary