6

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. :-)

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?

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?

Joe Eifert
  • 1,306
  • 14
  • 29
  • possible duplicate of [Disable ActiveRecord for Rails 4](http://stackoverflow.com/questions/19078044/disable-activerecord-for-rails-4) – webster Jun 10 '15 at 08:07

2 Answers2

13

Follow these steps

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

  2. 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"
    
  3. Delete database.yml, schema.rb and all the migrations

  4. Delete migration checks from test/test_helper.rb
  5. Delete all activerecord related configuration from config/environments

Hope this helps!

Source - Disable ActiveRecord for Rails 4

x-yuri
  • 16,722
  • 15
  • 114
  • 161
Rajdeep Singh
  • 17,621
  • 6
  • 53
  • 78
  • 1
    Yes it does, thanks. Do you also have input for the second part of my question? "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?" – Joe Eifert Feb 04 '15 at 10:37
  • 1
    This is a great answer. Also note that the wiki for the gem has a command you can use to set up a new rails app with neo4j without ActiveRecord: https://github.com/neo4jrb/neo4j/wiki/Neo4j-v3-Setup#usage-from-rails – Brian Underwood Feb 04 '15 at 12:22
-1

For those using the rails-api gem you may encounter a similar error when using the --skip-active-record flag when doing rails-api new my_api. The current fix (until a new corrected version of the gem is released) is to edit your rails-api gem to have this commit. Use bundle open and replace the old Gemfile with the new corrected one. Rerun and you should be all set.

Hardik Hardiya
  • 837
  • 6
  • 14