簡體   English   中英

具有資產的Rails gem未添加到config.assets.paths

[英]Rails gems that have assets are not added to config.assets.paths

我正在將Rails 3.0應用程序升級到Rails 4.2。 在Rails 3.1中添加資產管道后,我注意到包含資產的gem未添加到Rails.application.config.assets.paths

我將這些寶石添加到我的Gemfile

gem 'jquery-rails'
gem 'jquery-ui-rails'

我希望將這些目錄添加到Rails.application.config.assets.paths

 ~/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/jquery-ui-rails-5.0.5/app/assets/images
 ~/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/jquery-ui-rails-5.0.5/app/assets/javascripts
 ~/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/jquery-ui-rails-5.0.5/app/assets/stylesheets
 ~/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/jquery-rails-4.0.3/vendor/assets/javascripts

但是,它僅顯示我的app/assets文件夾中的文件夾。 這是Rails.application.config.assets的完整輸出。 我在其他Rails應用程序中具有完全相同的配置,我沒有遇到此問題。

 {:_blocks=>
   [#<Proc:0x007fa6070a9b50@~/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sprockets-rails-3.1.1/lib/sprockets/railtie.rb:126>,
    #<Proc:0x007fa6070a9948@~/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sprockets-rails-3.1.1/lib/sprockets/railtie.rb:130>,
    #<Proc:0x007fa6070a9600@~/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sprockets-rails-3.1.1/lib/sprockets/railtie.rb:137>,
    #<Proc:0x007fa6070a8fc0@~/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sprockets-rails-3.1.1/lib/sprockets/railtie.rb:149>,
    #<Proc:0x007fa6070a8958@~/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sprockets-rails-3.1.1/lib/sprockets/railtie.rb:153>,
    #<Proc:0x007fa6070a87f0@~/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sprockets-rails-3.1.1/lib/sprockets/railtie.rb:157>],
  :paths=>
   ["~/my-app/app/assets/images",
    "~/my-app/app/assets/javascripts",
    "~/my-app/app/assets/stylesheets"],
  :precompile=>
   [#<Proc:0x007fa6070ab680@~/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/sprockets-rails-3.1.1/lib/sprockets/railtie.rb:84 (lambda)>,
    /(?:\/|\\|\A)application\.(css|js)$/],
  :prefix=>"/assets",
  :manifest=>nil,
  :quiet=>false,
  :version=>"1.0",
  :debug=>true,
  :compile=>true,
  :digest=>true,
  :cache_limit=>52428800,
  :gzip=>true,
  :check_precompiled_asset=>true,
  :compress=>false,
  :raise_runtime_errors=>true,
  :enabled=>true,
  :logger=>false,
  :resolve_with=>[:environment]}

很可能你仍然在Gemfile擁有assets組。

assets分組概念是Rails 3的遺留物, 已在rails 4.0中刪除

Rails 4.0從Gemfile中刪除了資產組。 升級時,您需要從Gemfile中刪除該行。

在我最近從3.0升級到4.0的rails應用程序(包括assets組中的gem)阻止了gem資產包含在Rails.application.config.assets.paths 從Gemfile中刪除assets組,並更新捆綁包修復了問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM