ruby-on-rails 为什么我会得到“undefined method `start_with?”?

ev7lccsx  于 11个月前  发布在  Ruby
关注(0)|答案(1)|浏览(106)

我有一个Rails项目,我一直在更新到最新版本的Ruby和Rails。当我运行rake assets:precompile时,我得到以下错误:

NoMethodError: undefined method `start_with?' for /bootstrap-editable\/.*\.(?:png|gif)$/:Regexp (NoMethodError)

      str.start_with?("file://".freeze) && parse_asset_uri(str) ? true : false
         ^^^^^^^^^^^^
/usr/local/bundle/gems/sprockets-4.2.1/lib/sprockets/uri_utils.rb:78:in `valid_asset_uri?'
/usr/local/bundle/gems/sprockets-4.2.1/lib/sprockets/resolve.rb:27:in `resolve'
/usr/local/bundle/gems/sprockets-4.2.1/lib/sprockets/base.rb:79:in `find_asset'
/usr/local/bundle/gems/sprockets-4.2.1/lib/sprockets/base.rb:88:in `find_all_linked_assets'
/usr/local/bundle/gems/sprockets-4.2.1/lib/sprockets/manifest.rb:125:in `each'
/usr/local/bundle/gems/sprockets-4.2.1/lib/sprockets/manifest.rb:125:in `to_a'
/usr/local/bundle/gems/sprockets-4.2.1/lib/sprockets/manifest.rb:125:in `block (2 levels) in find'
/usr/local/bundle/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:24:in `block in execute'
/usr/local/bundle/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `block in synchronize'
/usr/local/bundle/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `synchronize'
/usr/local/bundle/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `synchronize'
/usr/local/bundle/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:22:in `execute'
/usr/local/bundle/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/promise.rb:564:in `block in realize'
/usr/local/bundle/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:352:in `run_task'
/usr/local/bundle/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:343:in `block (3 levels) in create_worker'
/usr/local/bundle/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `loop'
/usr/local/bundle/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `block (2 levels) in create_worker'
/usr/local/bundle/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `catch'
/usr/local/bundle/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `block in create_worker'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

字符串
我有最新版本的bootstrap-editable。还有什么可能导致此问题?

bgtovc5b

bgtovc5b1#

bootstrap-editable已经10年了,是时候让它去或分叉并修复它了。具体来说,这部分是问题:

  • 网址:http://github.com/bootstrap-ruby/bootstrap-editable-rails/blob/master/lib/bootstrap-editable-rails.rb#L12*
app.config.assets.precompile << %r(bootstrap-editable/.*\.(?:png|gif)$)

字符串
你不能用Regexp来定位预编译的资源,它在 Sprockets v4 中已经被manifest.js取代了。
.如果您以前使用的是regexp或proc值,那么它们在Sprockets 4中根本不起作用,如果您尝试,您将得到一个看起来像NoMethodError: undefined method 'start_with?'的异常

  • 网址:http://github.com/rails/sprockets/blob/main/UPGRADING.md#manifestjs*

相关问题