Skip to content
New issue

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

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

Already on GitHub? # to your account

Assets aren't precompiled with initialize_on_precompile=false #1135

Merged

Conversation

amacneil
Copy link
Contributor

Currently, if you set config.assets.initialize_on_precompile = false in application.rb (e.g. when deploying to Heroku), the rails_admin.css and js files don't get precompiled.

The workaround is to add them into config.assets.precompile manually, but this is messy and duplicating code.

This fix adds :group => :assets to the initializer in engine.rb, which evidently tells Rails to run it even if the application was not initialized. This was mentioned in the Rails 3.1.1 release notes:

"Plugins developers need to special case their initializers that are meant to be run in the assets group by adding :group => :assets. [José Valim]"
http://weblog.rubyonrails.org/2011/10/7/ann-rails-3-1-1/

Long story short, it means everything will work nicely if you set config.assets.initialize_on_precompile = false, without any extra configuration needed :)

@travisbot
Copy link

This pull request passes (merged 152dc34 into 76b3412).

@amacneil
Copy link
Contributor Author

Related issue: #1046

Existing workaround: https://github.com/sferik/rails_admin/wiki/Troubleshoot

@stevenh512
Copy link
Contributor

Nice. While I don't really see much reason to disable initialize_on_precompile on Heroku (I always use their user_env_compile feature, if you're using S3 for assets you probably need it for asset_sync anyway 😁), there are other situations where you might need to disable it and it's a good idea to make sure all the required assets are being precompiled in those cases.

@bbenezech
Copy link
Collaborator

@adrianmacneil you nailed it. Thanks. I couldn't understand why config.assets.precompile wasn't consistently run; I didn't have a clue about this.

bbenezech added a commit that referenced this pull request May 16, 2012
Assets aren't precompiled with initialize_on_precompile=false
@bbenezech bbenezech merged commit a78f183 into railsadminteam:master May 16, 2012
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants