Delete everything from all tables (in Mongoid)


Put below code in seed file and run rake db:seed

puts ‘EMPTY THE MONGODB DATABASE’
Mongoid.master.collections.reject { |c| c.name =~ /^system/}.each(&:drop)

OR

rake db:reset
It recreates your table from migrations

Cheers..!!!

I hope, i would help.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s