Rails 3.2 CSS not being precompiled

谁都会走 提交于 2019-12-23 04:51:33

问题


I have a Rails app and its throwing error in the browser We're sorry, but something went wrong.. I went on to checks on the logs, and this is what i get:

Compiled visitor.js  (0ms)  (pid 15667)
Compiled application.js  (3574ms)  (pid 15667)
Compiled visitor.css  (73ms)  (pid 15667)
Compiled aboutvideos.css  (1ms)  (pid 15667)
Compiled admin.css  (1ms)  (pid 15667)
Compiled bootstrap_and_overrides.css  (802ms)  (pid 15667)
Compiled jquery.fancybox.css  (0ms)  (pid 15667)
Compiled scaffolds.css  (8ms)  (pid 15667)
Compiled stores.css  (1ms)  (pid 15667)
Compiled application.css  (1001ms)  (pid 15667)


Started GET "/" for 190.166.197.58 at 2012-08-25 16:51:44 +0000
Processing by VisitorController#home as HTML
  Rendered visitor/home.html.erb within layouts/application (3.9ms)
Completed 500 Internal Server Error in 131ms

ActionView::Template::Error (visitor.css isn't precompiled):
    3: <head>
    4:   <title><%=h yield(:title) %></title>
    5:   <% if controller_name == "visitor" %>
    6:   <%= stylesheet_link_tag    "visitor", :media => "all" %>
    7:   <%= stylesheet_link_tag    "jquery.fancybox", :media => "all" %>
    8:   <%= javascript_include_tag "visitor" %>
    9:   <%= javascript_include_tag "jquery" %>
  app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb___794713378064579018_17000980'

As you can see the visitor.css is getting compiled, then i get error that visitor.css isnt precompiled. I have included the *=required visitor in the application.css. What's could be wrong?


回答1:


If you require visitor.css (*= require formtastic) within application.css, then you don't need to include it yourself (<%= stylesheet_link_tag "visitor", :media => "all" %>).

If you don't, then you have to add it in your production.rb:

config.assets.precompile += %w( visitor.css )


来源:https://stackoverflow.com/questions/12123928/rails-3-2-css-not-being-precompiled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!