Skip to content

Instantly share code, notes, and snippets.

@therabidbanana
Created January 30, 2012 21:46
Show Gist options
  • Save therabidbanana/1706920 to your computer and use it in GitHub Desktop.
Save therabidbanana/1706920 to your computer and use it in GitHub Desktop.
Fix broken mongo railtie
# lib/tasks/assets.rake
#
# adapted from: http://blog.noizeramp.com/2011/10/14/rails-3-asset-pipeline-on-heroku-when-using-mongoid/
#
pt = Rake::Task['assets:environment']
Rake.application.send(:eval, "@tasks.delete('assets:environment')")
namespace :assets do
task :environment do
module ::MongoMapper::Connection
def setup(*args)
puts "Skipping connection to Mongo DB"
end
def connect(env)
puts "Skipping connection to Mongo DB"
end
end
pt.execute
end
end
@bkeepers
Copy link

You shouldn't need to store off the original task and delete it. When you define a task that has already been defined, Rake doesn't override it, but adds to it.

@therabidbanana
Copy link
Author

Good point - do you know off-hand which order it executes them in though? Obviously this hack has to go before the other environment. I just copy-pasted it from that other blog post, didn't really look into how it worked. :)

@bkeepers
Copy link

bkeepers commented Jan 31, 2012 via email

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