information on creating indexes and hooking into mongoid rake tasks

This commit is contained in:
John Bintz 2012-10-18 15:49:06 -04:00
parent 66b8afe0d6
commit 87c771b96e
3 changed files with 29 additions and 3 deletions

View File

@ -1,10 +1,12 @@
NAME
----
mongoid-sequence
mongoid-grid_fs
INSTALL
-------
gem install mongoid-sequence
gem install mongoid-grid_fs
SYNOPSIS
--------
@ -33,3 +35,8 @@ DESCRIPTION
-----------
mongoid_sequence is a pure mongoid sequence generator based on mongodb's
increment operator
GRIDFS
------
Be sure to create indexes for the GridFS collections with `rake db:mongoid:create_indexes`.

View File

@ -51,6 +51,10 @@
require "digest/md5"
require "cgi"
if defined?(::Rails::Railtie)
require 'mongoid-grid_fs/railtie'
end
end
end
@ -134,9 +138,6 @@
namespace.send(:const_set, :File, file_model)
namespace.send(:const_set, :Chunk, chunk_model)
#at_exit{ file_model.create_indexes rescue nil }
#at_exit{ chunk_model.create_indexes rescue nil }
const_get(const)
end

View File

@ -0,0 +1,18 @@
module Mongoid
class GridFS
class Railtie < ::Rails::Railtie
rake_tasks do
task 'db:mongoid:create_indexes' do
::Mongoid::GridFS::Fs::File.create_indexes
::Mongoid::GridFS::Fs::Chunk.create_indexes
end
task 'db:mongoid:remove_indexes' do
::Mongoid::GridFS::Fs::File.remove_indexes
::Mongoid::GridFS::Fs::Chunk.remove_indexes
end
end
end
end
end