I need to be able to add indexes to my Mongoid database in a Padrino project. I saw that they added rake tasks for this here:
https:/开发者_JAVA技巧/github.com/padrino/padrino-framework/commit/ec8a267f477ac4dc88a66c84fffb17ac26190a22
And it seems that they should be accessed by doing this, but I get an error:
$ padrino-gen orm::mongoid --help
=> Problem loading ./config/boot.rb
=> Invalid option :index provided to relation :features. Valid options are: as, autosave, dependent, foreign_key, order, class_name, extend, inverse_class_name, inverse_of, name, relation, validate.
/Users/jeremysmith/.rvm/gems/ruby-1.9.2-p290/gems/mongoid-2.2.1/lib/mongoid/relations/options.rb:41:in `block in validate!'
Any idea of how to run a rake task to add indexes in Padrino?
Thanks!
When you generated your Padrino project, did you select mongoid as the persistence engine? Hint: easy to check by looking at the .components
file in your project root. If you did, you should be able to access the rake tasks just using padrino rake <namespace>:<task>
. See here: http://www.padrinorb.com/guides/rake-tasks#orm .
Running a rake task to create an index should be just: padrino rake mongoid:create_indexes
I would check padrino rake -T
to see the list of available tasks as well.
bundle exec padrino rake mi:create_indexes
(not mongoid:create_indexes as you will see elsewhere online)
This seems to be the new name for this rake task in Padrino 0.10.5 and Mongoid 2.3.4
精彩评论