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

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

Open
jensb opened this issue Dec 12, 2019 · 2 comments

Comments

@jensb
Copy link

jensb commented Dec 12, 2019

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'
@felixbuenemann
Copy link
Collaborator

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

@jensb
Copy link
Author

jensb commented Dec 13, 2019

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?

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

No branches or pull requests

2 participants