I’ve made a minor app, where a user can log in/out, be created and so forth. I’m using mySQL as the database and everything is working fine in local environment. But after I’ve deployed it to heroku and migrated the database and so forth, the heroku version doesn’t work. I’m getting this when I tail the log:
2011-10-20T18:48:22+00:00 app[web.1]: Started GET "/" for 83.233.57.240 at 2011-10-20 11:48:22 -0700
2011-10-20T18:48:22+00:00 app[web.1]: Processing by HomeController#index as HTML
2011-10-20T18:48:22+00:00 app[web.1]: Rendered home/index.html.erb within layouts/application (0.0ms)
2011-10-20T18:48:22+00:00 app[web.1]: Completed 500 Internal Server Error in 2ms
2011-10-20T18:48:22+00:00 app[web.1]:
2011-10-20T18:48:22+00:00 app[web.1]: ActionView::Template::Error (defaults.js isn't precompiled):
2011-10-20T18:48:22+00:00 app[web.1]: 3: <head>
2011-10-20T18:48:22+00:00 app[web.1]: 4: <title><%= content_for?(:title) ? yield(:title) : "Untitled" %></title>
2011-10-20T18:48:22+00:00 app[web.1]: 5: <%= stylesheet_link_tag "application" %>
2011-10-20T18:48:22+00:00 heroku[router]: GET afternoon-lightning-2154.heroku.com/ dyno=web.1 queue=0 wait=0ms service=7ms status=500 bytes=728
2011-10-20T18:48:22+00:00 app[web.1]: 6: <%= javascript_include_tag :defaults %>
2011-10-20T18:48:22+00:00 app[web.1]: 7: <%= csrf_meta_tag %>
2011-10-20T18:48:22+00:00 app[web.1]: 8: <%= yield(:head) %>
2011-10-20T18:48:22+00:00 app[web.1]: 9: </head>
2011-10-20T18:48:22+00:00 app[web.1]: app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb___2280146998680186378_39052620'
2011-10-20T18:48:22+00:00 app[web.1]:
2011-10-20T18:48:22+00:00 app[web.1]:
2011-10-20T18:48:22+00:00 app[web.1]: cache: [GET /] miss
I can see that it completes the 500 error at some point, but I have no idea why. Any suggestions to this? Thanks in advance!
Check that you have this in config/environments/production
Basically your problem is that your assets are not being automatically compiled.
More info here: http://devcenter.heroku.com/articles/rails31_heroku_cedar
Edit:
From Rails 3.1 we are going to be using the Assets pipeline. This means that you need to put all your assets (images, javascript, css) in
app/assets. Prior to 3.1 to would put those inpublic/**/*.In development mode Rails 3.1 is going to automatically compile ( minify both JS and CSS, transform images to base64 in some cases, etc) all your assets, creating a small, versioned package.
For a practical example, run
bundle exec rake assets:precompilein your project. Take a look at the new folder inpublic/. You can safely delete it after.In production mode this is not automatic. You may either enable automatic compilation of the assets, or manually run
bundle exec rake assets:precompilebefore deployment.More info on the Assets Pipeline
http://guides.rubyonrails.org/asset_pipeline.html
Useful: https://github.com/dnagir/guard-rails-assets