Ruby 在 Rails 上 Mongo 数据库
Ruby on Rails with Mongo DataBase
我是这个话题的新手。
我一直在尝试在我的 Windows OS.I 上安装 运行 MongoDB 安装 MongoId
rails g mongoid:config
以上命令没有创建配置文件。
我创建了文件 manually.I 跳过了 ActionController gem 在 App.To 创建期间使用 mongoId 配置文件 rails app.
但是,我不确定如何在 mongoDB 中启动服务器。
而insert Into it in Rails application.In 大部分Blog Post 都跳出了这一步
MongoDB 中的文档不是 clear.Please,请帮助我在 [=27] 上的 rails 应用程序中正确安装和启动、插入和检索来自 MongoDB 的数据=] OS.
首先,您应该在Windows上安装MongoDB(参考this link)
然后将 mongoid
添加到 Gemfile。
gem 'mongoid', '~> 5.0.0.beta'
运行 bundle install
.
然后运行rails g mongoid:config
生成mongoid.yml
然后通过命令 rails server
或 rails s
启动 rails 服务器
Mongoid supports all expected CRUD operations for those familiar with other Ruby mappers like Active Record or Data Mapper
如果你想插入一个文档到mongodb,你可以这样做:
Person.create(
first_name: "Heinrich",
last_name: "Heine"
)
从mongodb获取文档:
Person.where(first_name: "Heinrich")
您可以从 here
获取更多信息
我是这个话题的新手。 我一直在尝试在我的 Windows OS.I 上安装 运行 MongoDB 安装 MongoId
rails g mongoid:config
以上命令没有创建配置文件。 我创建了文件 manually.I 跳过了 ActionController gem 在 App.To 创建期间使用 mongoId 配置文件 rails app.
但是,我不确定如何在 mongoDB 中启动服务器。 而insert Into it in Rails application.In 大部分Blog Post 都跳出了这一步
MongoDB 中的文档不是 clear.Please,请帮助我在 [=27] 上的 rails 应用程序中正确安装和启动、插入和检索来自 MongoDB 的数据=] OS.
首先,您应该在Windows上安装MongoDB(参考this link)
然后将 mongoid
添加到 Gemfile。
gem 'mongoid', '~> 5.0.0.beta'
运行 bundle install
.
然后运行rails g mongoid:config
生成mongoid.yml
然后通过命令 rails server
或 rails s
Mongoid supports all expected CRUD operations for those familiar with other Ruby mappers like Active Record or Data Mapper
如果你想插入一个文档到mongodb,你可以这样做:
Person.create(
first_name: "Heinrich",
last_name: "Heine"
)
从mongodb获取文档:
Person.where(first_name: "Heinrich")
您可以从 here
获取更多信息