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

NoMethodError when using with Rails 6.0.0.beta2 #3116

Closed
alea12 opened this issue Mar 2, 2019 · 5 comments
Closed

NoMethodError when using with Rails 6.0.0.beta2 #3116

alea12 opened this issue Mar 2, 2019 · 5 comments

Comments

@alea12
Copy link

alea12 commented Mar 2, 2019

Overview

Environment

$ ruby -v
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin16]
$ rails -v
Rails 6.0.0.beta2

How to reproduce

$ rails _6.0.0.beta2_ new testapp
$ cd testapp
$ echo "gem 'rails_admin', '~> 1.3'" >> Gemfile
$ bundle install
$ rails g rails_admin:install
/Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rails_admin-1.4.2/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb:40:in `<class:AuditingAdapter>': undefined method `strip_heredoc' for #<String:0x00007fcb7325c718> (NoMethodError)
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rails_admin-1.4.2/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb:32:in `<module:PaperTrail>'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rails_admin-1.4.2/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb:3:in `<module:Extensions>'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rails_admin-1.4.2/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb:2:in `<module:RailsAdmin>'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rails_admin-1.4.2/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb:1:in `<main>'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-6.0.0.beta2/lib/active_support/dependencies.rb:297:in `block in require'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-6.0.0.beta2/lib/active_support/dependencies.rb:263:in `load_dependency'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-6.0.0.beta2/lib/active_support/dependencies.rb:297:in `require'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rails_admin-1.4.2/lib/rails_admin/extensions/paper_trail.rb:1:in `<main>'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-6.0.0.beta2/lib/active_support/dependencies.rb:297:in `block in require'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-6.0.0.beta2/lib/active_support/dependencies.rb:263:in `load_dependency'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-6.0.0.beta2/lib/active_support/dependencies.rb:297:in `require'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rails_admin-1.4.2/lib/rails_admin.rb:8:in `<main>'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:76:in `each'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:76:in `block in require'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:65:in `each'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:65:in `require'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.0.1/lib/bundler.rb:114:in `require'
	from /Users/alea12/projects/sandbox/testapp/config/application.rb:7:in `<top (required)>'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:92:in `require'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:92:in `preload'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:153:in `serve'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `run'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
	from /Users/alea12/.rbenv/versions/2.5.1/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
	from -e:1:in `<main>'

Notes

  • I've tested bundling my gems with bundle install --path=vendor/bundle, but it didn't solve this issue.
@seanwmitchell
Copy link

I am experiencing the same. Although I am using 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin18]

I also agree that it is just isolated to the Rails Admin gem definitely. Without it the rails server with rails 6.0.0beta2 starts fine.

@alea12
Copy link
Author

alea12 commented Mar 25, 2019

Update: Tested again with Ruby 2.6.0 + Rails 6.0.0.beta3, but the result was the same.

@Alexander-Senko
Copy link
Contributor

I haven't got any approval yet, but it looks like String#strip_heredoc has been deprecated since Rails has moved to Ruby 2.3. Just replace it with <<~ heredoc syntax for Ruby 2.3+.

@Alexander-Senko
Copy link
Contributor

I haven't got any approval yet, but it looks like String#strip_heredoc has been deprecated since Rails has moved to Ruby 2.3. Just replace it with <<~ heredoc syntax for Ruby 2.3+.

Sorry, it's still present in ActiveSupport 6.0.0.beta3. So, I wonder how we manage to get the exception this way.

Anyway, replacing it with <<~ should fix the problem.

@alea12
Copy link
Author

alea12 commented Apr 10, 2019

@SoftPro Thanks for reaching out! As an alternative, requiring ActiveSupport explicitly in auditing_adapter.rb also solved the problem for me. This should also work for ruby < 2.3

require 'active_support/core_ext/string/strip'

module RailsAdmin
  module Extensions
    module PaperTrail
      class VersionProxy
        # ...
      end

      class AuditingAdapter
        # ...
        E_VERSION_MODEL_NOT_SET = <<-EOS.to_s.strip_heredoc.freeze
          # ...
        EOS
        # ...
      end
    end
  end
end

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

4 participants