草庐IT

mongomapper

全部标签

ruby-on-rails - MongoMapper 和迁移

我正在构建一个Rails应用程序,使用MongoDB作为后端,使用MongoMapper作为ORM工具。假设在版本1中,我定义了以下模型:classSomeModelincludeMongoMapper::Documentkey:some_key,Stringend后来在第2版中,我意识到我需要在模型上添加一个新的必需键。所以,在版本2中,SomeModel现在看起来像这样:classSomeModelincludeMongoMapper::Documentkey:some_key,Stringkey:some_new_key,String,:required=>trueend如何迁移

ruby-on-rails - 未定义方法 `key?' 为 nil :NilClass when using MongoMapper

我按照theseinstructions设置了一个新的Rails应用程序.我生成了一个新Controller并将resources:tickets添加到路由文件中。Hexapoda::Application.routes.drawdoresources:ticketsend这是Controller(`/app/controllers/tickets_controller.rb')。classTicketsController然后我在/app/models/ticket.rb中添加了一个新模型Ticket。classTicketincludeMongoMapper::Documentke