Created
September 30, 2011 02:34
-
-
Save dustMason/1252515 to your computer and use it in GitHub Desktop.
Fix precompilation DB dependency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :assets do | |
# Prepend the assets:precompile_prepare task to assets:precompile. | |
task :precompile => :precompile_prepare | |
# This task will be called before assets:precompile to optimize the | |
# compilation, i.e. to prevent any DB calls. | |
task 'precompile_prepare' do | |
# Without this assets:precompile will call itself again with this var set. | |
# This basically speeds things up. | |
# ENV['RAILS_GROUPS'] = 'assets' | |
# Devise uses this flag to prevent connecting to the db. | |
ENV['RAILS_ASSETS_PRECOMPILE'] = 'true' | |
# Prevent loading observers which will load the models which in turn may hit the DB. | |
module ActiveModel::Observing::ClassMethods | |
def instantiate_observers; end | |
end | |
# Prevent route drawing because certain gems might get called which will hit the DB. | |
class ActionDispatch::Routing::RouteSet | |
def draw; end | |
end | |
end | |
end |
glad it worked!
…On Sep 30, 2011, at 12:05 PM, Jon Roberts wrote:
I can finally precompile my assets! Thanks for this.
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/1252515
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I can finally precompile my assets! Thanks for this.