Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClosureTree inside other gem #203

Closed
Exelord opened this issue Feb 28, 2016 · 3 comments
Closed

ClosureTree inside other gem #203

Exelord opened this issue Feb 28, 2016 · 3 comments
Labels

Comments

@Exelord
Copy link

Exelord commented Feb 28, 2016

Hi @mceachen,
Im working on Hierarchical access management system with roles inheritance gem and I want to use your solution. But...

When I have sth like (example bellow) inside my gem's model file

require 'closure_tree'

class Hierarchy < ActiveRecord::Base
  has_closure_tree
end

I always get:


/usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:570:in `retrieve_connection': No connection pool for Hierarchy (ActiveRecord::ConnectionNotEstablished)
    from /usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
    from /usr/local/lib/ruby/gems/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/connection_handling.rb:87:in `connection'
    from /usr/local/lib/ruby/gems/2.2.0/gems/closure_tree-6.0.0/lib/closure_tree/support_attributes.rb:60:in `quoted_hierarchy_table_name'
    from /usr/local/lib/ruby/gems/2.2.0/gems/closure_tree-6.0.0/lib/closure_tree/model.rb:14:in `block in <module:Model>'
    from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/concern.rb:120:in `class_eval'
    from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/concern.rb:120:in `append_features'
    from /usr/local/lib/ruby/gems/2.2.0/gems/closure_tree-6.0.0/lib/closure_tree/has_closure_tree.rb:25:in `include'
    from /usr/local/lib/ruby/gems/2.2.0/gems/closure_tree-6.0.0/lib/closure_tree/has_closure_tree.rb:25:in `has_closure_tree'

Do you maybe know how can I fix it? I will be very appreciate :)

@tomalok
Copy link

tomalok commented Jun 27, 2016

@Exelord seems you came across something similar to what I'm currently experiencing in #223 -- were you able to track down / fix your issue?

@Exelord
Copy link
Author

Exelord commented Jun 28, 2016

Yep, fortunately :)
Please take a look at my gem: Monarchy

I cannot initialize closure_tree during gem loading cuz of no database connection, so I moved the part with acts_as_tree to an app folder, which is automatically merged with project's app folder.

And it is working very well :)

@tomalok
Copy link

tomalok commented Jun 28, 2016

hm... this is already in the app directory tree, not being packaged by a gem.

i did a bit of troubleshooting late yesterday -- a my original proof-of-concept code worked (but was a sinatra app, it's now a CLI app). I got the new app working when I added sinatra-activerecord to the Gemfile. Presumably that's adding some necessary initialization, haven't figured out what that might be, yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants