1

I have a rails 3.2 app, and it is giving me the ol' 'We're sorry but something went wrong.' message when I deploy to heroku. A check of the logs has

2013-11-13T17:27:25.599927+00:00 app[web.1]: Started GET "/" for 54.247.188.179 at 2013-11-13 17:26:25 +0000
2013-11-13T17:27:25.599927+00:00 app[web.1]: 
2013-11-13T17:27:25.599234+00:00 app[web.1]:   Rendered static_pages/root.html.erb within layouts/application (5.9ms)
2013-11-13T17:27:25.599506+00:00 app[web.1]: Completed 500 Internal Server Error in 7ms
2013-11-13T17:27:25.600076+00:00 app[web.1]: Completed 500 Internal Server Error in 7ms
2013-11-13T17:27:25.600076+00:00 app[web.1]:   Rendered static_pages/root.html.erb within layouts/application (6.1ms)
2013-11-13T17:27:25.600076+00:00 app[web.1]:     10: 
2013-11-13T17:27:25.600076+00:00 app[web.1]: ActionView::Template::Error (static_pages.css isn't precompiled):
2013-11-13T17:27:25.600076+00:00 app[web.1]:     9: 

Along with some other stuff that looks very similar. I have been working on this for quite a bit and seen some other similar questions, so I'll head off some potential problems you think I might have:

  • I have no public/assets folder on my local before pushing to heroku
  • I have the line config.assets.enabled = true in my application.rb
  • I have the line config.assets.initialize_on_precompile = false in my application.rb

Thanks in advance, happy to supply more info.

Resolved

Apparently in order to get that css to compile correctly I had to add this line to config/environments/production.rb:

    config.assets.enabled = true

Thanks to Tyler for that one.

Savanaly
  • 347
  • 3
  • 10
  • 1
    Looks like you're not precompiling `static_pages.css`. I don't know if that's intentional, but you can avoid fallback to the assets pipeline if a precompiled asset is missed by setting `config.assets.compile = true` in your `config/environments/production.rb` – Tyler Nov 13 '13 at 17:49
  • Wow Tyler, you were dead on, thank you so much. I have no clue why that was necessary though -- I've certainly never touched that line of code in my project before, and it was working fine for a long time. Is it supposed to be false by default? – Savanaly Nov 13 '13 at 18:07

2 Answers2

0

You need to build a list of assets to be precompiled.

For example, in your config/environments/production.rb:

config.assets.precompile += %w( foo.js foo.scss static_pages.css)
Winfield
  • 18,985
  • 3
  • 52
  • 65
0

Looks like you're not precompiling static_pages.css. I don't know if that's intentional, but you have 2 options:

Option 1: Avoid fallback to the assets pipeline if a precompiled asset is missed. You can do so by setting:

# config/environments/production.rb
config.assets.compile = true

This will cause rails to compile your uncompiled file on the fly, rather than throwing an error (which it is doing now). More on this setting here: config.assets.compile=true in Rails production, why not?

Option 2: Make sure the file is being precompiled. You can do so by setting:

# config/environments/production.rb
config.assets.precompile += ['admin.js', 'admin.css', 'static_pages.css']

This will cause rails to precompile and include the stylesheet in your asset pipeline. More on this setting here: What is the purpose of config.assets.precompile?

Community
  • 1
  • 1
Tyler
  • 11,272
  • 9
  • 65
  • 105