ActionView::Template::Error (960.css isn't precompiled)

后端 未结 3 1644
抹茶落季
抹茶落季 2020-12-15 17:40

I have an iframe which renders a partial and is not part of the main application layout or asset pipeline.

I\'d like to include some style sheets, however I am ge

3条回答
  •  甜味超标
    2020-12-15 18:19

    If you have a lot of standalone assets, then instead of adding each one to the list, like this

    config.assets.precompile += ['960sm.css']
    

    you may want to just precompile everything, like this:

    def precompile?(path)
      %w(app lib vendor).each do |asset_root|
        assets_path = Rails.root.join(asset_root, 'assets').to_path
        return true if path.starts_with?(assets_path)
      end
      false
    end
    
    # Precompile all assets under app/assets (unless they start with _)
    Rails.application.config.assets.precompile << proc do |name, path|
      starts_with_underscore = name.split('/').last.starts_with?('_')
      unless starts_with_underscore
        path = Rails.application.assets.resolve(name).to_path unless path # Rails 4 passes path; Rails 3 doesn't
        precompile?(path)
      end
    end
    

    (Based on the code in the Rails Guide.)

提交回复
热议问题