如何从现有的Rails 4应用程序中删除ActiveRecord?

问题描述:

我开始了一个Ruby on Rails项目,该项目包括一个带有ActiveRecord和Neography的简单推荐系统.现在,我发现了有关 neo4j.rb 的信息,这将大大简化我的生活. :-)

I started off a Ruby on Rails Project which includes a simple recommender system with ActiveRecord and Neography. Now I found out about neo4j.rb, which is going to simplify my life by a lot. :-)

到现在为止,我了解到,可以在没有ActiveRecord的情况下创建新的应用程序,如下所示:

I learned by now, that I could create a new Application without ActiveRecord as follows:

rails new xyz -O

我可以这样做,然后将我的大多数文件/代码复制粘贴到该新项目中.还是有更简单的方法?

I could do that and copy paste most of my files / code into that new project. Or is there an easier way?

我仍在考虑该步骤是否必要.是否可以同时使用neo4j.rb和ActiveRecord?我正在考虑在Neo4j中使用ActiveRecord和我的推荐系统运行身份验证系统(例如Devise).有没有人有使用这种方法的经验?

I am still thinking about if that step is even necessary. Is it possible to use both neo4j.rb and ActiveRecord in parallel? I am thinking of running the authentication system (e.g. Devise) with ActiveRecord and my recommender system in neo4j. Does anyone have experiences with such an approach?

执行以下步骤

  1. 从Gemfile中删除数据库适配器gem,例如mysql2,sqlite3等

  1. Remove database adapter gems from your Gemfile, e.g., mysql2, sqlite3, etc

application.rb中删除require 'rails/all'并需要框架(在这些

From application.rb, remove require 'rails/all' and require frameworks (among those available in your rails version, the list varies, do not just copy) you want to use, for example:

require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"

  • 删除database.ymlschema.rb和所有迁移

  • Delete database.yml, schema.rb and all the migrations

    希望这会有所帮助!

    源-禁用ActiveRecord for Rails 4