1
votes

I am attempting to upgrade from Ruby 1.9.3 to Ruby 2.1.2 (Rails 4.0). I am using RVM.

I installed Ruby 2.1.2, updated the Gemfile, including specifying "gem 'paper_trail', '~> 3.0.5'", switched to Ruby 2.1.2 with RVM, created a new gemset, and switched to it.

I then did a bundle install.

When I attempt to run rails server, I get the following error:

/Users/sjohnson/my_app/config/initializers/paper_trail.rb:2:in <top (required)>': uninitialized constant PaperTrail::Rails::Engine (NameError) from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/zeus-0.13.3/lib/zeus/load_tracking.rb:50:in load' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/zeus-0.13.3/lib/zeus/load_tracking.rb:50:in load' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/zeus-0.13.3/lib/zeus/load_tracking.rb:43:in load' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/railties-4.0.5/lib/rails/engine.rb:609:in block (2 levels) in <class:Engine>' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/railties-4.0.5/lib/rails/engine.rb:608:in each' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/railties-4.0.5/lib/rails/engine.rb:608:in block in <class:Engine>' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/railties-4.0.5/lib/rails/initializable.rb:30:in instance_exec' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/railties-4.0.5/lib/rails/initializable.rb:30:in run' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/railties-4.0.5/lib/rails/initializable.rb:55:in block in run_initializers' from /Users/sjohnson/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:226:in block in tsort_each' from /Users/sjohnson/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:348:in block (2 levels) in each_strongly_connected_component' from /Users/sjohnson/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:418:in block (2 levels) in each_strongly_connected_component_from' from /Users/sjohnson/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:427:in each_strongly_connected_component_from' from /Users/sjohnson/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:417:in block in each_strongly_connected_component_from' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/railties-4.0.5/lib/rails/initializable.rb:44:in each' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/railties-4.0.5/lib/rails/initializable.rb:44:in tsort_each_child' from /Users/sjohnson/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:411:in call' from /Users/sjohnson/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:411:in each_strongly_connected_component_from' from /Users/sjohnson/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:347:in block in each_strongly_connected_component' from /Users/sjohnson/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in each' from /Users/sjohnson/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in call' from /Users/sjohnson/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in each_strongly_connected_component' from /Users/sjohnson/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:224:in tsort_each' from /Users/sjohnson/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:205:in tsort_each' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/railties-4.0.5/lib/rails/initializable.rb:54:in run_initializers' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/railties-4.0.5/lib/rails/application.rb:215:in initialize!' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/railties-4.0.5/lib/rails/railtie/configurable.rb:30:inmethod_missing' from /Users/sjohnson/my_app/config/environment.rb:5:in <top (required)>' from /Users/sjohnson/my_app/spec/spec_helper.rb:10:inrequire' from /Users/sjohnson/my_app/spec/spec_helper.rb:10:in <top (required)>' from /Users/sjohnson/my_app/spec/api/v1/api_authentication_spec.rb:1:in require' from /Users/sjohnson/my_app/spec/api/v1/api_authentication_spec.rb:1:in <top (required)>' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/rspec-core-3.0.3/lib/rspec/core/configuration.rb:1057:in load' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/rspec-core-3.0.3/lib/rspec/core/configuration.rb:1057:in block in load_spec_files' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/rspec-core-3.0.3/lib/rspec/core/configuration.rb:1057:in each' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/rspec-core-3.0.3/lib/rspec/core/configuration.rb:1057:in load_spec_files' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:97:in setup' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:85:in run' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:70:in run' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:38:in invoke' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/gems/rspec-core-3.0.3/exe/rspec:4:in ' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/bin/rspec:23:in load' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/bin/rspec:23:in ' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/bin/ruby_executable_hooks:15:in eval' from /Users/sjohnson/.rvm/gems/ruby-2.1.2@rails4/bin/ruby_executable_hooks:15:in '

I attempted to run: bundle exec rails generate paper_trail:install

It indicated that the migration file already existed (PaperTrail was working under 1.9.3). So, I ran it again: bundle exec rails generate paper_trail:install -s

It completed successfully, but I have the same issue.

config/initializers/paper_trail.rb:

# the following line is required for PaperTrail >= 3.0.3 with Rails
PaperTrail::Rails::Engine.eager_load!

module PaperTrail
  class Version < ActiveRecord::Base
    attr_accessible :captain
  end
end `

Ideas? Other information that would be helpful?

Edit: Despite the reference to paper_trail 3.0.3 in the initializer file, the gem is at version 3.0.5 (as verified by doing a gem list). The references to 3.0.3 in the error trace are for Rspec.

1
They have updated paper_trail version to 3.0.5 and removed version 3.0.3 with this constant resolving. I just did in my initializer module PaperTrail module Rails class Engine < ::Rails::Engine paths['app/models'] << 'lib/paper_trail/frameworks/active_record/models' end end endSergei Avanesov
I added the code to my initializer, and that appears to be working. If you enter this information as an answer, rather than a comment, I can accept it. Thanks.SamuelLJohnson

1 Answers

1
votes

I just did in my initializer:

module PaperTrail  
  module Rails  
    class Engine < ::Rails::Engine 
      paths['app/models'] << 'lib/paper_trail/frameworks/active_record/models'  
    end 
  end 
end

And I recommend you to put this:

PaperTrail::Rails::Engine.eager_load!`

as the last string in initializer.