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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.