具有资产的Rails gem未添加到config.assets.paths

时间:2016-08-17 17:20:07

标签: jquery ruby-on-rails jquery-ui rubygems asset-pipeline

我正在将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]}

1 个答案:

答案 0 :(得分:2)

您很可能仍然拥有assets中的Gemfile群组。

assets分组概念是Rails 3中的遗物,has been removed in rails 4.0

  

Rails 4.0从Gemfile中删除了资产组。你需要删除   升级时来自Gemfile的那一行。

在我最近从3.0升级到4.0的导轨应用中,包括assets组中的宝石阻止了宝石资产被包含在Rails.application.config.assets.paths中。从Gemfile中删除assets组,并更新捆绑包修复了问题。