Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do you add public/assets in version control?

In rails 3.1, when you precompile the assets, rails create public/assets directory and add files there.

Do you version-control public/assets/*?

like image 242
Sam Kong Avatar asked Sep 26 '11 20:09

Sam Kong


2 Answers

I use Capistrano to deploy. The last step is compiling the assets. Nothing like that gets checked into version control.

https://github.com/capistrano/capistrano/wiki/Documentation-v2.x

Checking in compiled assets, .gz files/etc, will just clutter up version control.

like image 113
Travis Avatar answered Oct 21 '22 17:10

Travis


I was looking for an answer to this too. I found the official Rails Guide has some thoughts on this:

http://guides.rubyonrails.org/asset_pipeline.html#local-precompilation

Here's a quote of the relevant section (emphasis added):

There are several reasons why you might want to precompile your assets locally. Among them are:

  • You may not have write access to your production file system.
  • You may be deploying to more than one server, and want to avoid duplication of work.
  • You may be doing frequent deploys that do not include asset changes.

Local compilation allows you to commit the compiled files into source control, and deploy as normal.

There are three caveats:

  • You must not run the Capistrano deployment task that precompiles assets.
  • You must ensure any necessary compressors or minifiers are available on your development system.
  • You must change the following application configuration setting:

In config/environments/development.rb, place the following line:

config.assets.prefix = "/dev-assets"

The prefix change makes Sprockets use a different URL for serving assets in development mode, and pass all requests to Sprockets. The prefix is still set to /assets in the production environment. Without this change, the application would serve the precompiled assets from /assets in development, and you would not see any local changes until you compile assets again.

In practice, this will allow you to precompile locally, have those files in your working tree, and commit those files to source control when needed. Development mode will work as expected.

So, it looks like it might be a good idea to put precompiled assets into VCS on occasion.

like image 45
dayer4b Avatar answered Oct 21 '22 15:10

dayer4b