[英]Rails gems that have assets are not added to config.assets.paths
I am upgrading a Rails 3.0 application to Rails 4.2. 我正在将Rails 3.0应用程序升级到Rails 4.2。 Upon adding the asset pipeline in Rails 3.1, I noticed that gems that contain assets are not added to
Rails.application.config.assets.paths
在Rails 3.1中添加资产管道后,我注意到包含资产的gem未添加到
Rails.application.config.assets.paths
I added these gems to my Gemfile
我将这些宝石添加到我的
Gemfile
gem 'jquery-rails'
gem 'jquery-ui-rails'
I would expect that to add these directories to Rails.application.config.assets.paths
我希望将这些目录添加到
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
However, it only shows the folders in my app/assets
folder. 但是,它仅显示我的
app/assets
文件夹中的文件夹。 Here is the complete output of Rails.application.config.assets
. 这是
Rails.application.config.assets
的完整输出。 I have the exact same configuration in other Rails applications where I am not experiencing this problem. 我在其他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]}
Quite likely you still have the assets
group in the Gemfile
. 很可能你仍然在
Gemfile
拥有assets
组。
The assets
grouping concept is a relic from Rails 3, and has been removed in rails 4.0 assets
分组概念是Rails 3的遗留物, 已在rails 4.0中删除
Rails 4.0 removed the assets group from Gemfile.
Rails 4.0从Gemfile中删除了资产组。 You'd need to remove that line from your Gemfile when upgrading.
升级时,您需要从Gemfile中删除该行。
On a rails app that I upgraded recently from 3.0 to 4.0, including the gems in assets
group prevented the gem assets from being included in Rails.application.config.assets.paths
. 在我最近从3.0升级到4.0的rails应用程序(包括
assets
组中的gem)阻止了gem资产包含在Rails.application.config.assets.paths
。 Removing the assets
group from the Gemfile, and updating the bundle fixed the problem. 从Gemfile中删除
assets
组,并更新捆绑包修复了问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.