Heroku error when using config.assets.initialize_on_precompile = false #1046

Closed
drale2k opened this Issue Mar 24, 2012 · 8 comments

Comments

Projects
None yet
6 participants

drale2k commented Mar 24, 2012

Using:
Rails 3.2.0
bootstrap-sass 2.0.1
latest Rails_Admin

Heroku requires to use

config.assets.initialize_on_precompile = false

for assets:precompile to work. Now after setting that i can't access Rails Admin on heroku anymore. Having aseets:precompile working is really important for me since it takes up to 20 seconds sometimes to load the app after a deploy.

This is the error from the logs

2012-03-24T20:13:48+00:00 app[web.2]: Completed 500 Internal Server Error in 148ms
2012-03-24T20:13:48+00:00 app[web.2]: 
2012-03-24T20:13:48+00:00 app[web.2]: ActionView::Template::Error (rails_admin/rails_admin.css isn't precompiled):
2012-03-24T20:13:48+00:00 app[web.2]:     5:     %meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
2012-03-24T20:13:48+00:00 app[web.2]:     6:     %meta{:content => "NONE,NOARCHIVE", :name => "robots"}
2012-03-24T20:13:48+00:00 app[web.2]:     7:     = csrf_meta_tag
2012-03-24T20:13:48+00:00 app[web.2]:     8:     = stylesheet_link_tag "rails_admin/rails_admin.css", :media => :all
2012-03-24T20:13:48+00:00 app[web.2]:     9:     = javascript_include_tag "rails_admin/rails_admin.js"
2012-03-24T20:13:48+00:00 app[web.2]:     10:   %body.rails_admin
2012-03-24T20:13:48+00:00 app[web.2]:     11:     .navbar.navbar-fixed-top

Using this did not help either:

config.assets.compile = true

Anything i can do?

drale2k commented Mar 28, 2012

I asked Heroku support and got this reply

This error occurs when you need to add additional files to config.assets.precompile. See:
http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets

In this case, I would imagine that the gem would add this for you, but because you're not initializing on precompile now, it is not being added automatically.

I guess i have to add the "rails_admin.css" and .js to "config.assets.precompile". Will test and report.

drale2k commented Mar 28, 2012

It worked, here is the solution

# Prevent initializing the application before assets are precompiled (required for heroku)
config.assets.initialize_on_precompile = false
# Add Rails Admin assets (required)
config.assets.precompile += ['rails_admin/rails_admin.css', 'rails_admin/rails_admin.js']

@drale2k drale2k closed this Mar 28, 2012

iscott commented May 30, 2012

+1 thanks drale2k, that solved it for me too.

I ran into this issue and found the same fix, but now that I've done that, deployment to Heroku seems to freeze at "Running: rake assets:precompile."

The weird thing is, deployment is actually still successful (I checked heroku logs, site, etc.), but for some reason my local command line freezes there. Anyone else encounter that after adding those files to the precompile list?

drale2k commented Jul 12, 2012

I've not deployed for some time now but the terminal did not freeze for me.

+1 That was exactly my issue. Thanks, my man.

rwilcox commented Aug 14, 2012

+1 my issue also. @ngottlieb I found this took 2-3 minutes to complete on my machine (well my VM).. so maybe you weren't patient enough (I'll admit I wasn't the first 2 times I tried)

thanks ran into this issue also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment