lib/padrino-gen/padrino-tasks/mongoid.rb in padrino-gen-0.9.25 vs lib/padrino-gen/padrino-tasks/mongoid.rb in padrino-gen-0.9.26

- old
+ new

@@ -1,11 +1,11 @@ if defined?(Mongoid) namespace :mi do desc 'Drops all the collections for the database for the current Padrino.env' task :drop => :environment do - Mongoid.master.mapions.select {|c| c.name !~ /system/ }.each(&:drop) + Mongoid.master.collections.select {|c| c.name !~ /system/ }.each(&:drop) end # Helper to retrieve a list of models. def get_mongoid_models documents = [] @@ -46,20 +46,20 @@ obj end end def collection_names - @collection_names ||= get_mongoid_models.map{ |d| d.mapion.name }.uniq + @collection_names ||= get_mongoid_models.map{ |d| d.collection.name }.uniq end desc "Convert string objectids in mongo database to ObjectID type" task :objectid_convert => :environment do collection_names.each do |collection_name| puts "Converting #{collection_name} to use ObjectIDs" # get old collection - collection = Mongoid.master.mapion(collection_name) + collection = Mongoid.master.collection(collection_name) # get new collection (a clean one) collection.db["#{collection_name}_new"].drop new_collection = collection.db["#{collection_name}_new"] @@ -74,11 +74,11 @@ puts "Done! Converted collection is in #{new_collection.name}\n\n" end # no errors. great! now rename _new to collection_name collection_names.each do |collection_name| - collection = Mongoid.master.mapion(collection_name) + collection = Mongoid.master.collection(collection_name) new_collection = collection.db["#{collection_name}_new"] # swap collection to _old puts "Moving #{collection.name} to #{collection_name}_old" collection.db["#{collection_name}_old"].drop @@ -105,11 +105,11 @@ end desc "Clean up old collections backed up by objectid_convert" task :cleanup_old_collections => :environment do collection_names.each do |collection_name| - collection = Mongoid.master.mapion(collection_name) + collection = Mongoid.master.collection(collection_name) collection.db["#{collection.name}_old"].drop end end end -end \ No newline at end of file +end