Rails 500 Error: application.css isn't precompiled
Asked Answered
S

3

5

I've got Rails running on Passenger with Apache on an Ubuntu linux box (ve) Server from Mediatemple. My app is giving me a 500 error (a Rails error, not an Apache error) when I try to load any page: http://www.mvngmtns.com

I saw an article about changing this line in config/environments/production.rb:

    config.assets.compile = true

But this didn't solve my problem. Can anyone help?

My development.log:

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'

As requested, ran

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

but still the same error. Here's what the trace said:

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

I still have the same "500 - We're sorry, but something went wrong" in the browser, and cache: [GET /] miss in the apache log file.

Savage answered 29/6, 2012 at 22:53 Comment(0)
P
6

After setting

config.assets.compile = true

you should also run:

 rake assets:precompile --trace RAILS_ENV=production

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

Polystyrene answered 29/6, 2012 at 23:4 Comment(0)
T
3

I don't know details on Mediatemple, but perhaps you need to precompile your assets before deploying:

rake assets:precompile
Triclinium answered 29/6, 2012 at 22:57 Comment(3)
Hi Matchu, I tried this also, but nothing changed. Here's the line it gave me: /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=assetsSavage
did you add the results to git repo?Fetish
I actually just ssh'ed in and ran the command in the project directorySavage
B
2

A couple things:

  1. check that the stylesheet actually gets compiled - it will be something like public/assets/application-XXX.css
  2. Passenger looks for APP_DIR/tmp/restart.txt, not /tmp/restart.txt, so make sure you touch the file in the right place
Bissextile answered 2/7, 2012 at 16:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.