rails 4 asset pipeline image subdirectories

前端 未结 2 1475
梦谈多话
梦谈多话 2021-01-31 06:18

I know this is probably an easy question but I am stumped here.

The application I am working on houses assets like so:

app
--assets
----fonts
----image         


        
2条回答
  •  失恋的感觉
    2021-01-31 06:46

    In Rails 4+ any changes to asset paths should be made in:

    config/initializers/assets.rb

    To add all subdirectories in app/assets/images to the path, add the following:

    Dir.glob("#{Rails.root}/app/assets/images/**/").each do |path|
      Rails.application.config.assets.paths << path
    end
    

    Afterwards, you can verify the asset paths in the rails console with the following:

    Rails.application.config.assets.paths.each do |p|
      puts p
    end
    

提交回复
热议问题