Skip to content

Neo4j::Rails Scaffolds & Generators

andreasronge edited this page Apr 27, 2012 · 9 revisions

Rails Neo4j Project Template

Make sure you are running JRuby (rvm install jruby).
Creating an Neo4j application from scratch:

gem install rails
rails new myapp -m http://andreasronge.github.com/neo4j/rails.rb
rails generate scaffold User name:string email:string
rails s

open a webbrowser: http://localhost:3000/users

Neo4j.rb Scaffolds

For available commands for neo4j models:


rails generate model —help

Example:

rails generate scaffold Post title:string —timestamps

Installation and Configuration

If you don’t want to use the Neo4j Project template above you can do it yourself.

Replace ActiveRecord with Neo4j

Edit the config/application.rb
comment the line require ‘rails/all’ and add

require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie" 
require 'neo4j'

Remove all references to active record in config/application.rb and config/environment/*

Include Dependency to Neo4j

Add the following line to your Gemfile
gem 'neo4j', '2.0.0'
and remove all sql gems. Install the gems specified in your Gemfile bundle install

Clone this wiki locally