[Rails] Bug in per model connections ?
Daniel Hobe
daniel at nightrunner.com
Tue Nov 2 17:56:09 GMT 2004
Attached is a patch that fixes the behavior.
Daniel Hobe wrote:
> I've been using per model connections for a project and I think I've run
> into a but in AR. Everything is fine until I go to save my changes back
> to the database (in my case Postgres). At that point I get a
> ConnectionNotEstablished exception. From what I've been able to track
> down it looks like the bug is on line 97 of
> lib/active_record/transactions.rb:
>
>
> def save_with_transactions(perform_validation = true) #:nodoc:
> ....
> ---> ActiveRecord::Base.transaction { result =
> save_without_transactions(perform_validation) }
> ....
> end
>
> It seems using ActiveRecord::Base.transaction rather than
> myModel.transaction is causing the lookup of an established connection
> in Thread.current['active_connections'] to try and find a connection for
> ActiveRecord::Base rather than myModel.
>
> Has anyone else seen this?
>
-------------- next part --------------
--- activerecord-1.0.0/lib/active_record/transactions.rb 2004-10-17 18:15:07.000000000 -0700
+++ activerecord-1.0.0.b/lib/active_record/transactions.rb 2004-11-02 09:42:06.000000000 -0800
@@ -94,9 +94,9 @@
if TRANSACTION_MUTEX.locked?
result = save_without_transactions(perform_validation)
else
- ActiveRecord::Base.transaction { result = save_without_transactions(perform_validation) }
+ self.class.transaction { result = save_without_transactions(perform_validation) }
end
return result
end
end
-end
\ No newline at end of file
+end
More information about the Rails
mailing list