I have an iframe which renders a partial and is not part of the main application layout or asset pipeline.
我有一个iframe,它呈现部分并且不是主应用程序布局或资产管道的一部分。
I'd like to include some style sheets, however I am getting this error:
我想要包含一些样式表,但是我收到此错误:
ActionView::Template::Error (960sm.css isn't precompiled):
Rails 3.1 Heroku
Rails 3.1 Heroku
3 个解决方案
#1
41
Style sheets that are not included in a manifest (directly by name or indirectly via require_tree) are not precompiled, so will not accessible in production.
未包含在清单中的样式表(直接通过名称或间接通过require_tree)未预编译,因此无法在生产中访问。
You need to add the sheet to the list of items to precompile in the environment application.rb.
您需要将工作表添加到要在环境application.rb中预编译的项目列表中。
config.assets.precompile += ['960sm.css']
And then access it in the view:
然后在视图中访问它:
stylesheet_link_tag('960sm')
#2
4
Instead of managing a list of CSS files, you may prefer to simply adjust the extension by adding .scss to the filename.
您可能更愿意通过将.scss添加到文件名来调整扩展名,而不是管理CSS文件列表。
Hence, 960sm.css would become 960sm.css.scss.
因此,960sm.css将变为960sm.css.scss。
This should not break anything as valid CSS is valid SCSS.
这不应该破坏任何东西,因为有效的CSS是有效的SCSS。
#3
0
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.)
(基于Rails指南中的代码。)
#1
41
Style sheets that are not included in a manifest (directly by name or indirectly via require_tree) are not precompiled, so will not accessible in production.
未包含在清单中的样式表(直接通过名称或间接通过require_tree)未预编译,因此无法在生产中访问。
You need to add the sheet to the list of items to precompile in the environment application.rb.
您需要将工作表添加到要在环境application.rb中预编译的项目列表中。
config.assets.precompile += ['960sm.css']
And then access it in the view:
然后在视图中访问它:
stylesheet_link_tag('960sm')
#2
4
Instead of managing a list of CSS files, you may prefer to simply adjust the extension by adding .scss to the filename.
您可能更愿意通过将.scss添加到文件名来调整扩展名,而不是管理CSS文件列表。
Hence, 960sm.css would become 960sm.css.scss.
因此,960sm.css将变为960sm.css.scss。
This should not break anything as valid CSS is valid SCSS.
这不应该破坏任何东西,因为有效的CSS是有效的SCSS。
#3
0
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.)
(基于Rails指南中的代码。)