NoSQL Zone is brought to you in partnership with:

Max De Marzi, is a seasoned web developer. He started building websites in 1996 and has worked with Ruby on Rails since 2006. The web forced Max to wear many hats and master a wide range of technologies. He can be a system admin, database developer, graphic designer, back-end engineer and data scientist in the course of one afternoon. Max is a graph database enthusiast. He built the Neography Ruby Gem, a rest api wrapper to the Neo4j Graph Database. He is addicted to learning new things, loves a challenge and finding pragmatic solutions. Max is very easy to work with, focuses under pressure and has the patience of a rock. Max is a DZone MVB and is not an employee of DZone and has posted 60 posts at DZone. You can read more from them at their website. View Full User Profile

Neo4j on Heroku - Part 3

01.19.2012
| 4384 views |
  • submit to reddit

This is the third and final installment of the Neo4j on Heroku tutorial.  After reading this, you should be ready to go out there and start hacking on Neo4j and then deploying your apps to Heroku.




This week we learned that leaving the create_graph method accessible to the world was a bad idea. So let’s go ahead and delete that route in Sinatra, and instead create a Rake Task for it.

In Rakefile:

require 'neography/tasks'
require './neoflix.rb'

namespace :neo4j do
  task :create do
    neo = Neography::Rest.new(ENV['NEO4J_URL'] || "http://localhost:7474")
    create_graph(neo)
  end
end

That’s much better. We can create our graph locally with

rake neo4j:create

or we can run it on Heroku with

heroku run rake neo4j:create
Log in to Heroku, the go to your apps https://api.heroku.com/myapps, click on your application (I’ll click on Neoflix) then on the “addons” drop down menu on the right, select Neo4j, and you’ll see this screen come up:

You can zip up the contents of your Neo4j database to neoflix.zip and perform a restore operation.

cd neo4j/data/graph.db
zip -r neoflix.zip .

Your Neo4j addon will restart and all your data will be loaded and ready to go.

If you have followed part 1 and part 2 of this series, then you should take what you have learned and create a Neo4j demo application. Take part in the Neo4j Challenge and have a chance at winning awesome prices as well as learning a new technology.



Source:  http://maxdemarzi.com/2012/01/18/neo4j-on-heroku-part-three/
Published at DZone with permission of Max De Marzi, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)