I am upgrading my rails app from 5.1.4 to 5.2.0. I am getting the following error. I would appreciate any help debugging this. I have not put the entire stack trace below, please let me know if you need it.
I have paper_trail version 12.1.0 installed. Its odd though, I had been using ruby version 2.5.1 with rails version 5.1.4 and it never gave me errors. This error started only after I upgraded to rails 5.2.0
redd#tanya:~/galaxy$ rails s
[DEPRECATED] Bootsnap's `autoload_paths_cache:` option is deprecated and will be removed. If you use Zeitwerk this option is useless, and if you are still using the classic autoloader upgrading is recommended.
[DEPRECATED] Bootsnap's `disable_trace:` option is deprecated and will be removed. If you use Ruby 2.5 or newer this option is useless, if not upgrading is recommended.
DEPRECATION WARNING: The factory_girl gem is deprecated. Please upgrade to factory_bot. See https://github.com/thoughtbot/factory_bot/blob/v4.9.0/UPGRADE_FROM_FACTORY_GIRL.md for further instructions. (called from <main> at /home/redd/galaxy/config/application.rb:9)
=> Booting Puma
=> Rails 5.2.7 application starting in development
=> Run `rails server -h` for more startup options
/home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activerecord-5.2.7/lib/active_record/type.rb:27: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activerecord-5.2.7/lib/active_record/type/adapter_specific_registry.rb:9: warning: The called method `add_modifier' is defined here
/home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activemodel-5.2.7/lib/active_model/type/integer.rb:13: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activemodel-5.2.7/lib/active_model/type/value.rb:8: warning: The called method `initialize' is defined here
/home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activerecord-5.2.7/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb:12: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activemodel-5.2.7/lib/active_model/type/value.rb:8: warning: The called method `initialize' is defined here
Exiting
Traceback (most recent call last):
120: from bin/rails:3:in `<main>'
119: from bin/rails:3:in `load'
....
8: from /home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-5.2.7/lib/active_support/dependencies.rb:661:in `new_constants_in'
7: from /home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-5.2.7/lib/active_support/dependencies.rb:476:in `block in load_file'
6: from /home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:39:in `load'
5: from /home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:39:in `load'
4: from /home/redd/galaxy/app/models/users/user.rb:1:in `<main>'
3: from /home/redd/galaxy/app/models/users/user.rb:2:in `<class:User>'
2: from /home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted/adapters/active_record.rb:131:in `method_missing_with_attr_encrypted'
1: from /home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/attr_encrypted-3.1.0/lib/attr_encrypted.rb:306:in `method_missing'
/home/redd/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activerecord-5.2.7/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `has_paper_trail' for #<Class:0x000055c56bb2be30> (NoMethodError)
Did you mean? has_attached_file
Get the full stack trace (not the shortened version you listed above)
Find the lines containing /home/redd/galaxy/config/initializers
Insert the following code at the top of these files:
# Loading `User` below would fail
# if `User.has_paper_trail` is not loaded already
require "paper_trail/frameworks/active_record"
Related
I'm following this guide to get started with Ruby on Rails.
I ran ruby new <projectName>
When I do rails server I get
Traceback (most recent call last):
2: from bin/rails:2:in `<main>'
1: from bin/rails:2:in `load'
<projectName>/bin/spring:7:in `<top (required)>': undefined method `specs' for nil:NilClass (NoMethodError)
No searching on SO has revealed anything so far.
I think it could be related to the build process.
When I run bundle install, it goes through the process before seeming to stall out
Fetching sassc 2.4.0
Installing sassc 2.4.0 with native extensions
Killed
I only get this if bundle install didn't run to completion. If you skipped that step or interrupted it the Gemfile.lock isn't properly generated.
The line is:
Bundler.locked_gems.specs.find { ... }
Where Bundler.locked_gems returns nil in the case of a missing .lock file.
This should be better communicated with a proper error message.
I am working on an existing project, which was made around 2014. While running bundle exec rake db:migrate I get the following error:
bundle exec rake db:migrate
D:/Ruby/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.0.0/lib/active_support/core_ext/object/duplicable.rb:82: warning: BigDecimal.new is deprecated; use BigDecimal() method instead.
D:/Ruby/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.0.0/lib/active_support/values/time_zone.rb:282: warning: circular argument reference - now
D:/Ruby/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.0.0/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Fixnum is deprecated
D:/Ruby/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-4.0.0/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Bignum is deprecated
rake aborted!
SystemStackError: stack level too deep
rake aborted!
NoMethodError: undefined method `reject' for nil:NilClass
Traceback (most recent call last):
D:/Ruby/Ruby26-x64/bin/rake: stack level too deep (SystemStackError)
D:/Ruby/Ruby26-x64/bin/rake: undefined method `reject' for nil:NilClass (NoMethodError)
9: from D:/Ruby/Ruby26-x64/bin/rake:23:in `<main>'
8: from D:/Ruby/Ruby26-x64/bin/rake:23:in `load'
7: from D:/Ruby/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
6: from D:/Ruby/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
5: from D:/Ruby/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:185:in `standard_exception_handling'
4: from D:/Ruby/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:195:in `rescue in standard_exception_handling'
3: from D:/Ruby/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:208:in `display_error_message'
2: from D:/Ruby/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:218:in `display_exception_details'
1: from D:/Ruby/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:249:in `display_exception_backtrace'
D:/Ruby/Ruby26-x64/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/backtrace.rb:21:in `collapse': undefined method `reject' for nil:NilClass (NoMethodError)
My Ruby version is 2.6.6p146, and Rails 4.0.0 (as required by the gemfile)
I've also read similar issues and tried gem update --system, but the same problem persists.
I can't really speak to that Rails 4 won't run on Ruby 2.6. But there's always a possibility that you hit subtle issues, depending on the features you use and the gems that you include. From Ruby 2.4, it has the Fixnum and Bignum unification, as well as unicode changes - which potentially could have an impact.
I suggest you to upgrade Rails version to 6 or downgrade Ruby version to 2.2.
Before writing this question I looked at these answers, but was unable to find a solution.:
Error when execute rails generate scaffold User name:string email:string
rake aborted! undefined method `migration_error=' for ActiveRecord::Base:Class
Error launching Rails server: undefined method 'configure'
When I try to start a new application (for Hartl's tutorial, Chapter 2), at the stage scaffold start, I got an error like:
**undefined method `configure' for #<SampleApp2::Application:0x00000101a74610> (NoMethodError)**
But thanks to the above examples, I edited the development.rb file:
DemoApp::Application.configure do
(Yes, my application is called demo_app so I transformed its name).
After that, I tried to run scaffold again but got a new error:
**method_missing': undefined method raise_in_transactional_callbacks=' for ActiveRecord::Base:Class (NoMethodError)**
In response to similar cases indicates a migration method - that it should be removed from the file development.rb. Similarly, I tried to find in this file raise_in_transactional_callbacks method, but it's not there!
In addition, I would say that the full code that produces in cmd is very large:
C:\Sites\demo_app>rails generate scaffold User name:string email:string
invoke active_record
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `raise_in_transactional_callbacks=' for ActiveRecord::Base:Class (NoMethodError)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/active_record/railtie.rb:166:in `block (3 levels) in <class:Railtie>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/active_record/railtie.rb:165:in `each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-4.0.2/lib/active_record/railtie.rb:165:in `block (2 levels) in <class:Railtie>'
…
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-4.0.2/lib/rails/commands.rb:48:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
Where the ...(ellipsis) - specially cut similar code.
That's all. I would be grateful for any help!
Your config/application.rb has the following line:
config.active_record.raise_in_transactional_callbacks = true
This is not a valid configuration value in your version of Rails. You will need to delete it or comment it out to continue.
Note: this error and the one that preceded it are indicative of an incomplete Rails version change. If you are in the early stages of a tutorial, you might seriously consider restarting your application using your preferred version of Rails from the very start. This will help you avoid this type of error until you are more familiar with the technology.
I had the same issue when upgrading an app from Rails 5.0.1 to Rails 5.1.0.beta1.
When starting the server (rails s), I got the following error message:
/home/user01/.rvm/gems/ruby-2.4.0#global/gems/activerecord-5.1.0.beta1/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `raise_in_transactional_callbacks=' for ActiveRecord::Base:Class (NoMethodError)
Same ills, same cures.
Commenting out the following line, in config/application.rb, solved the issue...
config.active_record.raise_in_transactional_callbacks = true
After some investigation, I found that this line was default in Rails 4.2.1, vanished in Rails 5.0.0, and now raises an error in Rails 5.1.0.beta1...
If you don't see config.active_record.raise_in_transactional_callbacks = true in config/application.rb it might exist in your environment configs. For my app it was being set it in config/environments/development.rb and config/environments/test.rb
Our rails project version is 2.3.3. Recently, however, we decided to upgrade rails version to 2.3.17 to patch the security holes.
But after upgrade my rails gem, I got the following error.
Is there anyone whoh had a same problem?
benjamins-iMac:webapp benjamin$ script/server
=> Booting WEBrick
=> Rails 2.3.17 application starting on http://0.0.0.0:3000
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/rails-2.3.17/lib/rails/gem_dependency.rb:21.
/Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/activerecord-2.3.17/lib/active_record/associations.rb:48: warning: already initialized constant HasManyThroughCantAssociateThroughHasManyReflection
/Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/activesupport-2.3.17/lib/active_support/whiny_nil.rb:52:in `method_missing': undefined method `name' for nil:NilClass (NoMethodError)
from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/rails-2.3.17/lib/initializer.rb:445:in `initialize_database_middleware'
from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/rails-2.3.17/lib/initializer.rb:182:in `process'
from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/rails-2.3.17/lib/initializer.rb:113:in `send'
from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/rails-2.3.17/lib/initializer.rb:113:in `run'
from /Users/benjamin/clue/webapp/config/environment.rb:6
from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/activesupport-2.3.17/lib/active_support/dependencies.rb:182:in `require'
from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/activesupport-2.3.17/lib/active_support/dependencies.rb:182:in `require'
from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/activesupport-2.3.17/lib/active_support/dependencies.rb:547:in `new_constants_in'
from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/activesupport-2.3.17/lib/active_support/dependencies.rb:182:in `require'
from /Users/benjamin/.rvm/gems/ruby-1.8.7-p370/gems/rails-2.3.17/lib/commands/server.rb:84
from script/server:3:in `require'
from script/server:3
benjamins-iMac:webapp benjamin$
And the ruby-1.8.7-p370/gems/rails-2.3.17/lib/initializer.rb:445's code is
ActionController::Base.session_store.name == 'ActiveRecord::SessionStore'
I resolved the problem.
The answer was at here.
http://johnpwood.net/2009/09/04/disabling-sessions-in-rails-2-3-4/
The error is never enough information to go off of alone. however, so simple things, did you run: sudo rake gems:install already?
Also, the database columns must be present for your ActiveRecord models to pick up. If the initial state is "no-database" and subsequent rake tasks call on models, then it would choke on nils. I see environment.rb in the stack trace, so I assume it got that far...
So you should note that if you are upgrading from older version to the newer one then environment.rb file also needs to be changed apart from others. See carefully the changes that you need to done specially the initializer tasks as all the problem lies there according to the error log.
my application is on rails 3.2.1 ,rake 0.9.2.2, gems 1.8.15 it is working fine on local host.
As i trying to deploy on engineyard am getting the error message in there log file
/usr/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require': iconv will be deprecated in the future, use String#encode instead.
/usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/engineyard-serverside-1.5.28/lib/vendor/thor/lib/thor/shell.rb:10: Use RbConfig instead of obsolete and deprecated Config.
/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/rubygems_integration.rb:219:inblock in replace_bin_path': can't find executable rake (Gem::Exception)
from /data/emailsending/releases/20120206123528/ey_bundler_binstubs/rake:16:in <main>'
/usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/engineyard-serverside-1.5.28/lib/engineyard-serverside/task.rb:62:inrun_on_roles': #, #server=#, #args=[false]> (EY::Serverside::RemoteFailure)
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/engineyard-serverside-1.5.28/lib/engineyard-serverside/task.rb:44:in run'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/engineyard-serverside-1.5.28/lib/engineyard-serverside/deploy.rb:278:inmigrate'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/engineyard-serverside-1.5.28/lib/engineyard-serverside/task.rb:34:in roles'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/engineyard-serverside-1.5.28/lib/engineyard-serverside/deploy.rb:275:inmigrate'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/engineyard-serverside-1.5.28/lib/engineyard-serverside/deploy.rb:160:in send'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/engineyard-serverside-1.5.28/lib/engineyard-serverside/deploy.rb:160:inrun_with_callbacks'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/engineyard-serverside-1.5.28/lib/engineyard-serverside/deploy.rb:37:in cached_deploy'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/engineyard-serverside-1.5.28/lib/engineyard-serverside/deploy.rb:457:inwith_failed_release_cleanup'
... 11 levels...
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/engineyard-serverside-1.5.28/lib/vendor/thor/lib/thor.rb:124:in start'
from /usr/local/ey_resin/ruby/lib/ruby/gems/1.8/gems/engineyard-serverside-1.5.28/bin/engineyard-serverside:10
from /usr/local/ey_resin/ruby/bin/engineyard-serverside:19:inload'
from /usr/local/ey_resin/ruby/bin/engineyard-serverside:19