Gem Load Error is: uninitialized constant ActsAsTree::InstanceMethods::ActiveRecord

#84 · open · 2 comments

View on GitHub ↗

jensb

I am getting this error when using `gem 'acts_as_tree'` in my Rails project's Gemfile. (Rails 5.2.4, Ruby 2.5.0, on Ubuntu Linux), also when adding a `, git: ` line to point to this repository. Why is the gem assuming "ActiveRecord" is a local constant inside the module? Even `::ActiveRecord` does not seem to help. acts_as_tree worked fine when I was using Rails 4.2 and Ruby 1.9.3 before starting the upgrade. ``` $ bundle exec rails c /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:84:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'acts_as_tree'. (Bundler::GemRequireError) Gem Load Error is: uninitialized constant ActsAsTree::InstanceMethods::ActiveRecord Did you mean? ActiveModel Backtrace for gem load error is: /home/jens/.bundle/ruby/2.5.0/acts_as_tree-2e2890a7c082/lib/acts_as_tree.rb:355:in `<module:InstanceMethods>' /home/jens/.bundle/ruby/2.5.0/acts_as_tree-2e2890a7c082/lib/acts_as_tree.rb:242:in `<module:ActsAsTree>' /home/jens/.bundle/ruby/2.5.0/acts_as_tree-2e2890a7c082/lib/acts_as_tree.rb:3:in `<top (required)>' /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:81:in `require' /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:81:in `block (2 levels) in require' /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:76:in `each' /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:76:in `block in require' /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:65:in `each' /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:65:in `require' /usr/lib/ruby/vendor_ruby/bundler.rb:114:in `require' ```

Comments

felixbuenemann

Looks like something with your Rails upgrade went bad or you’re requiring the gem before activerecord.

jensb

Weird, my application.rb looks like this: ``` # -*- encoding : utf-8 -*- require File.expand_path('../boot', __FILE__) require 'rails/all' # If you have a Gemfile, require the gems listed there, including any gems # you've limited to :test, :development, or :production. Bundler.require(:default, Rails.env=='selenium' ? 'test' : Rails.env) if defined?(Bundler) module Foobar class Application < Rails::Application ..... end end ``` This looks OK to me and it worked with Rails 4.2.1. What is wrong here?