Karl Baum
2010-Jul-29 14:37 UTC
connection_pool with_connection strange behaviour - ActiveRecord 2.3.8
I noticed some strange behaviour with connection_pool.with_connection and it''s probably because I am not understanding the proper usage. If I call with_connection, it seems to me that the connection within the block is not used with the ActiveRecord methods. First a simple == comparison. jruby-1.5.1 > ActiveRecord::Base.connection_pool.with_connection{|c| ActiveRecord::Base.connection==c } => false Then examining the number of active connections after using the with_connection method: => {"ActiveRecord ::Base"=>#<ActiveRecord::ConnectionAdapters::ConnectionPool:0x105b3e5d>} jruby-1.5.1 > ActiveRecord::Base.connection_pool.instance_eval{ @checked_out.length } => 0 jruby-1.5.1 > ActiveRecord::Base.connection_pool.with_connection{ |c| EmailAccount.last } jruby-1.5.1 > ActiveRecord::Base.connection_pool.instance_eval{ @checked_out.length } => 1 I found this lighthouse ticket https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1752 , but it seems to have been resolved. I am using ActiveRecord 2.3.8. thx. -karl -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.