【问题标题】:Rails 500 Error: application.css isn't precompiledRails 500 错误:application.css 未预编译
【发布时间】:2012-07-01 11:11:16
【问题描述】:

我在 Mediatemple 的 Ubuntu linux box (ve) 服务器上使用 Apache 运行 Rails。当我尝试加载任何页面时,我的应用程序给我一个 500 错误(Rails 错误,而不是 Apache 错误):http://www.mvngmtns.com

我在config/environments/production.rb中看到一篇关于改变这一行的文章:

    config.assets.compile = true

但这并没有解决我的问题。有人可以帮忙吗?

我的开发日志:

Started GET "/" for 72.225.170.239 at 2012-06-29 15:28:43 -0700
Processing by HomeController#index as HTML
Rendered application/_logo.html.erb (0.6ms)
Rendered application/_navbar.html.erb (1.4ms)
Rendered home/index.html.erb within layouts/application (2.6ms)
Completed 500 Internal Server Error in 6ms

ActionView::Template::Error (application.css isn't precompiled):
2: <html>
3: <head>
4:   <title>Moving Mountains<%= get_title %></title>
5:   <%= stylesheet_link_tag    "application", :media => "all" %>
6:   <%= javascript_include_tag "application" %>
7:   <%= csrf_meta_tags %>
8:
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___2841110860658336572_129641540'
app/controllers/home_controller.rb:6:in `index'

按要求运行

    rake assets:precompile --trace RAILS_ENV=production
    touch /tmp/restart.txt

但仍然是同样的错误。以下是踪迹所说的:

newguy@mvngmtns:/var/www/movingmountains$ rake assets:precompile --trace RAILS_ENV=production
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/usr/local/rvm/rubies/ruby-1.9.2-head/bin/ruby /usr/local/rvm/gems/ruby-1.9.2-head@global/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
** Invoke assets:precompile:nondigest (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:non digest

我仍然在浏览器中显示相同的“500 - 很抱歉,但出了点问题”,并在 apache 日志文件中缓存:[GET /] miss。

【问题讨论】:

    标签: ruby-on-rails apache passenger precompiled


    【解决方案1】:

    几件事:

    1. 检查样式表是否真的被编译了——它会像public/assets/application-XXX.css
    2. 乘客查找的是APP_DIR/tmp/restart.txt,而不是/tmp/restart.txt,因此请确保touch 文件位于正确的位置

    【讨论】:

      【解决方案2】:

      设置后

      config.assets.compile = true
      

      你也应该运行:

       rake assets:precompile --trace RAILS_ENV=production
      

      见:rails 3.1.0 ActionView::Template::Error (application.css isn't precompiled)

      【讨论】:

        【解决方案3】:

        我不知道有关 Mediatemple 的详细信息,但也许您需要在部署之前预编译您的资产:

        rake assets:precompile
        

        【讨论】:

        • 嗨,Matchu,我也试过了,但没有任何改变。这是它给我的行:/usr/local/rvm/rubies/ruby-1.9.2-head/bin/ruby /usr/local/rvm/gems/ruby-1.9.2-head@global/bin/rake assets :precompile:all RAILS_ENV=production RAILS_GROUPS=assets
        • 你把结果添加到 git repo 了吗?
        • 我其实只是在项目目录中ssh'ed并运行命令
        猜你喜欢
        • 2014-07-10
        • 1970-01-01
        • 1970-01-01
        • 2011-11-08
        • 2013-03-10
        • 1970-01-01
        • 1970-01-01
        • 2012-06-03
        • 1970-01-01
        相关资源
        最近更新 更多