2013-05-30 17 views
0

我试图在解决我的链接:问题的链接,获取消息“ie.css不预编译”

http://92.51.243.6/ 

不知道为什么他们不工作。我在说的链接是页面顶部的“主页”和“关于”。它在本地WEBrick模式下都可以正常工作。我听说Ajax可能是问题所在,所以我从这些链接中取出:remote => true,并在文件scripts.js中禁用ajax,该文件负责处理我的ajax。

中的链接的代码是:

<div id = "menu"> 
     <ul id = "home_page_links"> 
     <li><%= link_to "Home",about_us_path %></li> 
     <li><%= link_to "About Us",about_us_path %></li> 
     </ul> 
    </div> 

在我的routes.rb文件我有:

QuestionnaireSite::Application.routes.draw do 

    get "home", :to => "static_pages#about_us" 
    get "about_us", :to => "static_pages#about_us" 

的消息我得到的, '很抱歉,但出事了'是我公共文件夹中的错误页面。

当我运行:

tail -f /var/www/apps/myapp/current/log/production.log 

我得到:

Started GET "https://stackoverflow.com/users/sign_in" for 87.198.119.247 at Thu May 30 10:52:04 +0100 2013 
Processing by Devise::SessionsController#new as HTML 
    Rendered users/sessions/new.html.erb within layouts/devise (4.4ms) 
    Rendered layouts/_fb_init.html.erb (0.1ms) 
    Rendered layouts/_signed_out_header.html.erb (0.7ms) 
    Rendered layouts/_messages.html.erb (0.1ms) 
Completed 200 OK in 10ms (Views: 7.5ms | ActiveRecord: 0.3ms) 


Started GET "/about_us" for 87.198.119.247 at Thu May 30 11:02:29 +0100 2013 
Processing by StaticPagesController#about_us as HTML 
    Rendered static_pages/about_us.html.erb within layouts/application (0.0ms) 
Completed 500 Internal Server Error in 4ms 

ActionView::Template::Error (ie.css isn't precompiled): 
    12: <%= javascript_include_tag "application" %> 
    13: <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements --> 
    14: <!--[if lt IE 9]> 
    15:  <%= stylesheet_link_tag 'ie', :media => 'all' %> 
    16:  <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> 
    17: <![endif]--> 
    18: </head> 
    app/views/layouts/application.html.erb:15:in `_app_views_layouts_application_html_erb___1658874457_26880020' 

所以我得到一个错误:ie.css不预编译。

根据我的错误信息,我是否需要在第12行至第18行进行更改? 我做:

rake assets:precompile 

这似乎已成功完成,因为我得到了:

/home/app/.rvm/rubies/ree-1.8.7-2012.02/bin/ruby /home/app/.rvm/gems/[email protected]/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets 

我缺少的东西?

+0

您可以在其中传递一个数组config.assets您的配置文件添加以下行.precompile + = ['your.js','your.css'],因为你只有一个css会给你一个问题,所以你可以从清单中添加它。 (ref - http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets) –

回答

1

我认为,ie.css是在lib/assets/stylesheetsvendor/assets/stylesheets
把它列入预编译,加入config/environments/production.rb

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

你说,ie.css.scssapp/assets/stylesheets
我假设你application.css包含:

*= require_tree . 

然后ie.css.scss编译,在生产application.css微细化以及包含有不再是有条件的加载!

你的条件

14: <!--[if lt IE 9]> 
15:  <%= stylesheet_link_tag 'ie', :media => 'all' %> 
16:  <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> 
17: <![endif]--> 

尝试加载它第二次。
尝试删除stylesheet_link_tag并仅保留条件脚本。

如果你真的需要的CSS有条件地加载,将其移动到lib/assest/sytlesheet,因此不包括在application.css并如上所述增加assets.precompile

+0

实际上,这两个文件夹都是空的。 ie.css.scss等等,都在app/assets/stylesheets中。那是问题吗?所有其他样式表文件似乎部署好,只是不是ie.css之一。我应该继续并将config.assets.precompile + =%w(ie.css)添加到production.rb中,然后将其推送到服务器?谢谢。 – CHarris

+0

我扩展了我的答案 –

+0

实际上,我的application.css.scss没有* = require_tree。很多其他的东西,但没有。但是我在该文件夹中有很多其他css.scss文件,并且它们似乎工作正常。我将它添加到我的application.css文件中,重新部署并让你知道我如何继续。首先需要出去几个小时。谢谢你的帮助。 – CHarris

0

感谢马丁M等人,我解决了我的问题。

基本问题的要点是正是这样的错误我得到:

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

一开始,我并没有* =需要在我的application.css.scss文件,即,使我把它放进去。我有8或9个scss文件,因为某种原因(我从别人那里继承了这个项目),ie引用丢失了。

然后,我摆脱了代码的完全,在我application.html.erb:

<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements --> 
    <!--[if lt IE 9]> 
    <%#= stylesheet_link_tag 'ie', :media => 'all' %> 
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> 
    <![endif]--> 

我救了这一切,推起来掌握分支在GitHub上,然后从那里到分公司生产和部署它具有:(!其他问题之后,但至少部分工作)

cap production deploy:migrations 

它的工作现在