Rails 3.1 和 MongoDB - ActiveRecords?
我第一次尝试在 Rails 3.1 应用程序中使用 MongoDB 而不是 MySQL,但我对周围的规则有点困惑。
我知道 MongoDB 是 NoSQL 和文档数据库之类的东西。但我想问的是 - 我习惯于使用 MySQL 在表和脚手架生成和迁移之间建立关联。
是否可以在 MongoDB 中使用这里的工作?我试图在谷歌上找到一个很好的教程,但我仍然找不到关于它的好来源......
有没有人对这件事有任何好的建议?
非常感谢。
I try to use first time MongoDB instead of MySQL in my Rails 3.1 app and I am a bit confuse about the rules around.
I know MongoDB is NoSQL and document database and stuffs like that. But what I would like to ask, is - I am accustomed from a work with MySQL with an associations between tables and scaffold generating and migrations.
Is it possible to use here with a work in MongoDB? I try to find a good tutorial for this on Google, but I still can't find the good source about it...
Have anyone any good a tip around this things?
Many thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ActiveRecord 不适用于 MongoDB。你需要另一个图书馆。
我推荐 Mongoid。很好,文档很棒。一探究竟。
它安装了自己的发电机,所以你可以用脚手架离开。
哦,您不需要使用 MongoDB 进行迁移。
我还听说过关于 MongoMapper 的好消息。
ActiveRecord won't work with MongoDB. You need another library.
I recommend Mongoid. It's good, documentation is excellent. Check it out.
It installs its own generators, so you can scaffold away.
Oh, and you don't need migrations with MongoDB.
I also heard good things about MongoMapper.
是的,我使用 Mongoid,它真的很棒。
它与 ActiveRecord 非常相似,您可以轻松地执行相同的操作。还有mongoid的脚手架,例如:
将生成文章模型和所有链接的脚手架
Yes, I use Mongoid and it's really great.
It's very similar to ActiveRecord, and you can easily do the same things. There are also scaffolding for mongoid, for instance:
will generate the article model and all the linked scaffold