Skip to content

Instantly share code, notes, and snippets.

@subelsky
Created March 3, 2013 21:48
Show Gist options
  • Save subelsky/5078466 to your computer and use it in GitHub Desktop.
Save subelsky/5078466 to your computer and use it in GitHub Desktop.
Quick rake task to check if assets need to pre-compiled before deployment (since I don't like precompiling during deployment)
namespace :assets do
task :check do
root_dir = File.join(File.dirname(__FILE__),"..","..")
assets_last_modified_at = Dir["#{root_dir}/app/assets/**/**"].map { |p| File.mtime(p) }.sort.last
assets_last_compiled_at = Dir["#{root_dir}/public/assets/**/**"].map { |p| File.mtime(p) }.sort.last
if assets_last_modified_at > assets_last_compiled_at
fail "Assets need to precompiled; last asset modified at #{assets_last_modified_at}"
end
end
end
@subelsky
Copy link
Author

subelsky commented Mar 4, 2013

thanks guys! Nick looks like this is a solved problem, thanks!

@akitaonrails
Copy link

If you're in Rails 3 you can use this: https://github.com/ndbroadbent/turbo-sprockets-rails3

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