mongoid Rails mongodb 数据未清理
Rails 3.2.1
应用程序名称:演示
数据库:mongoDB 和 mongoid
我在 Rails 3.2.1 中设置了这个脚手架:localhost:3000/pages,
我有这些字段:标题、内容。
我已经在每个字段中填写了 3 行数据。
问题是:删除应用程序(通过删除根文件夹)并使用相同的脚手架(页面)创建相同的应用程序名称(演示)后,这 3 行数据仍然显示,而我不再想要了。
任何人都可以如何清理数据库吗?谢谢
Rails 3.2.1
app name: demo
database: mongoDB with mongoid
I have this scaffolding set up in rails 3.2.1: localhost:3000/pages,
and I have these fields: title, content.
I have already filled in 3 rows of data to each field.
The problem is: after deleting the app(by removing the root folder) and creating the same app name(demo) with the same scaffolding(pages), those 3 rows of data remain showing up which I don't want anymore.
Can anyone how to clean the database up?Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我知道的最简单的方法是
正如其他人所说,您也可以去 rake --tasks 并查看它
the simplest way that i'm aware of is
as others said, you can go to rake --tasks and see it as well
该数据库存在于您的应用程序之外,因此删除您的应用程序不会影响它。要清空或删除它,您需要使用 mongo 命令行或其他 mongo 工具。打开终端/命令提示符并输入:
您应该获得 mongo 命令行。切换到您的应用程序的数据库(它很可能采用
[app_name]_[environment]
形式:并使用 dropDatabase 命令:
The database exists outside your application, so deleting your application will not affect it. To empty or delete it you need to use the mongo command line or another mongo tool. Open up a terminal / command prompt and type:
And you should get the mongo command line. Switch to the DB for your app (it will most likely be of the form
[app_name]_[environment]
:And use the dropDatabase command:
以下是如何在应用程序命名空间中定义名为 db_reset 的任务的快速片段。如果 MongoId gem 已正确安装,它将删除系统和 Mongo DB
lib/tasks/app_name.rake:
Here is a quick snippet of how you can define a task, called db_reset, in your application namespace. It will drop both system and Mongo DBs given that MongoId gem is properly installed
lib/tasks/app_name.rake: