5

Mediatemple の Ubuntu Linux ボックス (ve) サーバー上で Apache を使用して Passenger で Rails を実行しています。ページを読み込もうとすると、アプリで 500 エラー (Apache エラーではなく Rails エラー) が表示されます: 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 ログ ファイルに cache: [GET /] miss があります。

4

3 に答える 3

6

設定後

config.assets.compile = true

次も実行する必要があります。

 rake assets:precompile --trace RAILS_ENV=production

参照: rails 3.1.0 ActionView::Template::Error (application.css はプリコンパイルされていません)

于 2012-06-29T23:04:34.883 に答える
3

Mediatemple の詳細はわかりませんが、デプロイする前にアセットをプリコンパイルする必要があるかもしれません。

rake assets:precompile
于 2012-06-29T22:57:14.337 に答える
2

いくつかのこと:

  1. スタイルシートが実際にコンパイルされることを確認してください - それは次のようになりますpublic/assets/application-XXX.css
  2. Passenger はAPP_DIR/tmp/restart.txtではなくを探します。そのため、ファイルが正しい場所にある/tmp/restart.txtことを確認してください。touch
于 2012-07-02T16:53:46.947 に答える