简体   繁体   English

在rails中从MongoDB迁移回ActiveRecord

[英]Migrating back from MongoDB to ActiveRecord in rails

When I migrated my MongoDB database back to a simple SQL database, I received some errors, mainly: 当我将MongoDB数据库迁移回简单的SQL数据库时,我收到了一些错误,主要是:

uninitialized constant BSON [NameError]

and

Cannot visit BSON::ObjectId

I followed this guide to perform my migration. 我按照指南执行迁移。

Any clue? 任何线索?

-frbl -frbl

It took me some hours to figure out, but it seemed to be extremely simple. 我花了几个小时才弄明白,但它看起来非常简单。 These are all steps I took. 这些都是我采取的步骤。 Note that this application did not contain any valuable information, so destroying everything was not an issue for me. 请注意,此应用程序不包含任何有价值的信息,因此销毁所有内容对我来说不是问题。

Remove all devise stuff (model, initializer, routes and views like described here Set the basic ORM models back to ActiveModels: 删除所有设计的东西(的模式,初始化,路线和意见等记述这里设置的基本ORM模型回ActiveModels:

code: 码:

config.generators do |g|
   g.orm :active_record
end

Re-install devise: 重新安装设备:

rails g devise:install
rails g devise user
rake db:migrate

now everything is set up, but the most important point, remove your session!! 现在一切都已设置,但最重要的一点,删除你的会话! What I dit was changing the secret code in config/initializers/secret_token.rb (according to this guide) 我在dit中更改了config / initializers / secret_token.rb中的密码(根据指南)

Took me 3 hours, so I hope it saves you some time. 花了我3个小时,所以我希望它可以节省你一些时间。

-frbl -frbl

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM