#341 Asset Pipeline in Production pro
The Asset Pipeline is very useful, but it can be a pain in production. Here I show why it works the way it does, and how to customize it to fit your deployment setup.
- Download:
- source code
- mp4
- m4v
- webm
- ogv
Awesome series on deployment for last few weeks. Really came handy for me. Thanks Ryan.
Thanks! Spent hours on making precompiling work. I also had problems with errors in external js files like the ckeditor. Had to fork the git and correct the errors to complete the precompiling.
Thanx for the local precompiling task.
Two things not mentioned:
1) If you're not relying on sprockets - say if you're using Compass to @import other stylesheets, your going to have to specify them in your production.rb. There is a commented-out config option to provide an array of files that should be pre-compiled.
2) Permissions. Still struggling with this one, but just keep an eye out for your web server's user/group having access to the public and tmp directories. (Perhaps not exactly related to the pipeline, but this is something that can come up while trouble shooting asset pipeline problems)
Nice cast, Ryan. Thank you! I wrote article in my blog a few weeks ago. Those article about deploying rails 3 application to heroku and assets to s3. I hope this theme will be interesting too for you and it is reasonable to make the next railscast about this kind of deploying assets.
when the first time using Asset Pipeline in production mode and get the "We're Sorry, but something went wrong." i thought that i was alone.. and then Google saved me :))
Great
I have trouble with assets and ssl in production . Anybody knows if is it a known issue?
Nnz
I've just set up a site using the pipeline and SSL - you've got to make sure you use the image_tag helper and protocol relative paths:
http://collectiveidea.com/blog/archives/2010/11/29/ssl-with-rails/
thank you but i have a loop :( don't know why
Asset Pipeline can be a little annoying if additional js/css other than application.{js,css} is required.
For example, with active_admin enabled, config/environments/production.rb needs a little change:
config.assets.precompile += %w( active_admin.js active_admin.css )
I would like to have this precompile array automatically set, but no good solution yet.
I use these lines to load my vendor assets into the precompile array dynamically, but your mileage may vary:
Nice 'cast...
Can anyone share an Apache2 config block that directs Apache to serve the static gzipped assets like nginx? The Rails guide is short on the topic...and my skills with setting up Apache config files are not good.
Oh, and there is a good writeup on SO that shows how to package up your assets to serve on a conditional basis (e.g., to specific versions of ie, etc.)
http://stackoverflow.com/questions/7134034/using-rails-3-1-assets-pipeline-to-conditionally-use-certain-css
Thanks!
It would be great if you could show how to use the asset pipeline, but use s3 or rackspace to serve the assets
See this article in my blog
Wow, how have I never learned the
t
command on github before... Thanks for the tip Ryan!the asset pipeline makes everything so easy /s
@Ryan 7:48 "We can cache these files like crazy"
That last one was some nice trick!
Very nice cast. That pipeline can get convoluted. Thank you!
A note that if you're using nginx compiled via passenger: It won't compile the gzip_static module. You need to pass it as a configure option. http://dennisreimann.de/blog/configuring-nginx-for-the-asset-pipeline/
When using a gem like Boostrap for example, how can we include the files provided by the gem to precompile. So far the only way I've been able to make it work is to copy the files needed from the gem to the Rails app. But I feel there must be way to include gem related files to the assets pipeline.
@rbates
If I have a custom font how do I load that into the rails app.
@font-face is used in pure html for fetching the font face.
This can be useful for people working on premium apps with their own fonts.
Does anyone seem to get
ActionView::Template::Error (require_tree argument must be a directory