rails 4 asset pipeline vendor assets images are not being precompiled

前端 未结 3 1900
失恋的感觉
失恋的感觉 2020-12-04 16:12

I\'m using rails 4 & ruby 1.9.3 for my application and fancybox2-rails gem, but there\'s a general problem with asset pipeline. If I run rake task

相关标签:
3条回答
  • 2020-12-04 16:45

    It seems like images are included by default only from app/assets folder. So the solution is to add this line to config/application.rb

    config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
    
    0 讨论(0)
  • 2020-12-04 16:53

    It sounds Sporker can't autoload images from vendor/assets/images.

    2.2 Asset Organization Pipeline assets can be placed inside an application in one of three locations: app/assets, lib/assets or vendor/assets.

    app/assets is for assets that are owned by the application, such as custom images, JavaScript files or stylesheets.

    lib/assets is for your own libraries' code that doesn't really fit into the scope of the application or those libraries which are shared across applications.

    vendor/assets is for assets that are owned by outside entities, such as code for JavaScript plugins and CSS frameworks

    From the description come from guides.rubyonrails.org, I don't think they ignored vendor/assets/images with no intention.

    So I just added the follow line:

    #config/application.rb
    config.assets.paths << Rails.root.join("vendor", "assets", "images")
    

    And, I solved my problem. I hope this will work for you.

    0 讨论(0)
  • 2020-12-04 17:07

    For my Rails 4.2.x project, I just moved the vendor images to vendor/assets/images and added this to application.rb:

    config.assets.precompile += %w(vendor/assets/images/*)
    

    Works fine on development and production.

    0 讨论(0)
提交回复
热议问题