Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

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

Comments

@drale2k
Copy link

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
Copy link
Author

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
Copy link
Author

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']

@iscott
Copy link

iscott commented May 30, 2012

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

@ngottlieb
Copy link

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
Copy link
Author

drale2k commented Jul 12, 2012

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

@howethomas
Copy link

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

@rwilcox
Copy link

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)

@ahmetabdi
Copy link

thanks ran into this issue also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants