elight/acts_as_commentable_with_threading

ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished) when gem is included

Closed this issue · 11 comments

I am getting this error bellow when ever I try to run the generator or try to create a migration when i have the gem installed...

Any idea?

/Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:318:in retrieve_connection': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished) from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:97:inretrieve_connection'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in connection' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/moretea-awesome_nested_set-1.4.3.1/lib/awesome_nested_set/base.rb:258:inquoted_left_column_name'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/moretea-awesome_nested_set-1.4.3.1/lib/awesome_nested_set/base.rb:72:in acts_as_nested_set' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/bundler/gems/acts_as_commentable_with_threading-31983bd/lib/comment.rb:5:inclass:Comment'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/bundler/gems/acts_as_commentable_with_threading-31983bd/lib/comment.rb:4:in <top (required)>' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:inrequire'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in block in require' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:inblock in load_dependency'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:591:in new_constants_in' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:inload_dependency'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in require' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/bundler/gems/acts_as_commentable_with_threading-31983bd/lib/acts_as_commentable_with_threading.rb:7:in<top (required)>'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0.rc.6/lib/bundler/runtime.rb:64:in require' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0.rc.6/lib/bundler/runtime.rb:64:inblock (2 levels) in require'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0.rc.6/lib/bundler/runtime.rb:62:in each' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0.rc.6/lib/bundler/runtime.rb:62:inblock in require'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0.rc.6/lib/bundler/runtime.rb:51:in each' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0.rc.6/lib/bundler/runtime.rb:51:inrequire'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0.rc.6/lib/bundler.rb:112:in require' from /Users/Pete/Sites/work/pollenizer/PitchBay/config/application.rb:7:in<top (required)>'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands.rb:15:in require' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands.rb:15:in<top (required)>'
from script/rails:6:in require' from script/rails:6:in

'

+1. same problem using rails 3 and ruby 1.9.2

same here: rails 3 / ruby 1.9.2 / postgres. any ideas?

same problem: rails 3 / ruby 1.9.2 / postgres.

also finding the same error: rails 3 / ruby 1.8.7 / sqlite (development box)

I have the same problem (rails 3 / ruby 1.9 / postgresql), but as the stacktrace shows, the root of the problem is within awesome_nested_set (and/or the postgresql adapter).

The model definition of awesome_nested_set creates a relation with an :order on "quoted_left_column_name" which is a method that calls connection.quote_column_name. With both MySQL and sqlite (sorry @firebelly, couldn't reproduce it with the latter), it is simply a matter of string quoting, but with the postgresql adapter, it calls pgconn.quote_ident (which, I assume, requires a database connection for some reason).
Removing the quoting in this method is enough to go ahead.

john commented

@stanguy, thanks very much for the guidance, huge help.

To get the migration to generate I edited awesome_nested_set.rb starting around line 235 like this:

def quoted_left_column_name
  # connection.quote_column_name(left_column_name)
  left_column_name
end

def quoted_right_column_name
  # connection.quote_column_name(right_column_name)
  right_column_name
end

Considering using this in a fairly large production environment--is this a minor bug or is this gem not ready for prime time?

Same problem here. Couldn't even start the server (rails 3.0.3 / ruby 1.9.2 / mysql)

This ought to work now with Rails 3. I tested under REE; however, the problem was due to Rails 3 seemingly loading the connection specifications at a different time than Rails 2.x.

Now, aacwt, when the generator is run, creates Rails.root/app/models/comment.rb as it probably should have from the get go. This way, you can tinker with/screw up comment.rb to your hearts' content. ;-)

Happy coding!

john commented

Awesome, thanks much for the fix--just did a bundle update and worked a charm. And thanks for aacwt--been banging on my patched version all week and loving it.

Great, it now also works with brady8/thumbs_up, a rails 3 aware replacement for acts_as_votable.

Shameless plug but, if you dig aacwt, feel free to give me a recommendation here: http://workingwithrails.com/person/10033-evan-david-light