-
Notifications
You must be signed in to change notification settings - Fork 274
Neo4j::Rails Scaffolds & Generators
Example of creating an Neo4j Application from scratch, type
gem install rails rails new myapp -m http://andreasronge.github.com/rails3.rb cd myapp bundle rails generate scaffold User name:string email:string rails s
open a webbrowser: http://localhost:3000/users
You can use the standard Rails 3 generators to create your models, controllers, routes, tests and views, by passing ‘neo4j’ as the ORM for generators to use:
> rails generate scaffold User name:string born:date --orm=neo4j
You can also set up your application configuration to use neo4j as the default ORM for generating templates. Simply add the following to your application’s Rails configuration. This example also favours RSpec and specifies that fixtures are not to be created:
config.generators do |g| g.orm :neo4j g.test_framework :rspec, :fixture => false end
Then you can simply call generators as normal without having to specify the ORM:
rails generate model Admin --parent User
To undo what was just generated:
rails destroy model Admin
To create a model with timestamps:
rails generate scaffold Post title:string --timestamps
If you don’t want to use the Neo4j Project template above you can do it yourself.
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 "sprockets/railtie" # Rails 3.1+ only
require 'neo4j'
Add the following line to your Gemfile
gem 'neo4j', '1.0.0'
and remove all sql gems. Install the gems specified in your Gemfile bundle install
WARNING: Much of the information in this wiki is out of date. We are in the process of moving things to readthedocs
- Project Introduction
- Neo4j::ActiveNode
- Neo4j::ActiveRel
- Search and Scope
- Validation, Uniqueness, and Case Sensitivity
- Indexing VS Legacy Indexing
- Optimized Methods
- Inheritance
- Core: Nodes & Rels
- Introduction
- Persistence
- Find : Lucene
- Relationships
- Third Party Gems & extensions
- Scaffolding & Generators
- HA Cluster