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? -- Daniel Hobe <daniel-Rb441GAJvreWkzVdRvz7FA@public.gmane.org> http://www.nightrunner.com
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? >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Daniel Hobe wrote:> Attached is a patch that fixes the behavior.Daniel (and everybody else), Thanks a lot for contributing to the framework! Please note that there is an issue/patch tracker for Rails at http://dev.rubyonrails.org, and it would be much more convenient if you''d post patches right there. To post a patch: create new ticket, attach your unified diff file to it, and prefix the Short Summary field with [PATCH]. Then it shows up in patches, not in tickets. Your friendly evil Wiki gnome, Alexey Verkhovsky
Yep, found that after I posted. I''ll open a ticket. Alexey Verkhovsky wrote:> Daniel Hobe wrote: > >> Attached is a patch that fixes the behavior. > > > Daniel (and everybody else), > > Thanks a lot for contributing to the framework! > > Please note that there is an issue/patch tracker for Rails at > http://dev.rubyonrails.org, and it would be much more convenient if > you''d post patches right there. > > To post a patch: create new ticket, attach your unified diff file to it, > and prefix the Short Summary field with [PATCH]. Then it shows up in > patches, not in tickets. > > Your friendly evil Wiki gnome, > Alexey Verkhovsky > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Daniel Hobe <daniel-Rb441GAJvreWkzVdRvz7FA@public.gmane.org> http://www.nightrunner.com