문제

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://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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top