views:

112

answers:

1

In the last couple of days, I've been trying to get a solution to an active_record issue that has been plaguing me. Posts on railsforum and stackoverflow have turned up completely dry. The length and level of detail in those posts may have dissuaded commentors, so I'm trying again - in brief.

Under windows, the trap behavior is normal in my scripts - until I "require 'active_record'," at which point traps no longer function properly. They fail to run at all and it is leaving my database in disarray.

The script in question interacts with other scripts on other systems through active record. When a user hits control-c or the script terminates for any other reason, it is critical that the script notify the database of its (the script's) impending doom before it exits. With trap out of commission, I'm stuck.

Is there a workaround? If you're interested in test code, see my linked posts. The problem can be reproduced in just a few lines.

Thanks...

+1  A: 

Have you considered updating Ruby on the Windows platform? I made some tests with your code sample and came out with the following results:

  • Ruby 1.8.6-p36, Gem 1.3.2, ActiveRecord 2.2.2: FAILS
  • Ruby 1.8.7-p72, Gem 1.3.1, ActiveRecord 2.1.0: WORKS
  • Ruby 1.8.7-p72, Gem 1.3.2, ActiveRecord 2.2.2: WORKS
  • Ruby 1.9.1-p0, Gem 1.3.1, ActiveRecord 2.3.2: WORKS sometimes
Romulo A. Ceccon