我试图将我的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']