预编译的css无法找到

时间:2014-09-04 10:03:18

标签: ruby-on-rails ruby-on-rails-4

我试图将我的CSS添加到我的布局中,并且我遇到了一个无法找到它的问题。

错误

Asset filtered out and will not be served: add `Rails.application.config.assets.precompile += %w( index.css )` to `config/initializers/assets.rb` and restart your server

守则

<head>
<title>Site</title>
<%= stylesheet_link_tag 'home', media: 'all' %>
<%= stylesheet_link_tag 'home/index' if params[:action] == 'index' %>
<%= csrf_meta_tags %>

  

奇怪的是我可以从&#39; localhost:3000 / assets / home / index.css&#39;

访问索引css文件

预编译资产

config.assets.paths << Rails.root.join("app", "assets", "fonts")
config.assets.paths << Rails.root.join("app", "assets", "stylesheets", "commons")
config.assets.paths << Rails.root.join("app", "assets", "stylesheets", "home")
config.assets.paths << Rails.root.join("app", "assets", "stylesheets", "access")

config.assets.precompile += ['home.css', 'access.css']
config.assets.precompile += ['home/index.css', 'access/login.css', 'access/register.css']
config.assets.precompile += ['access.js']

0 个答案:

没有答案