[Neo4j] Basic Ruby/Neo4j question

2011-05-11 Thread Vaccaro, Kristen M
Hi, I just started using Neo4j and I've got a pretty basic question. I've been 
running the gem using JRuby but I'm having trouble calling on edges/nodes I've 
made in previous transactions. So one of the very basic example scripts I've 
been working with looks like:

require rubygems
require 'neo4j'
Neo4j::Transaction.run do
a = Neo4j::Node.new :name = 'A'
b = Neo4j::Node.new :name = 'B'
c = Neo4j::Node.new :name = 'C'
d = Neo4j::Node.new :name = 'D'
e = Neo4j::Node.new :name = 'E'
a.outgoing(:friends)  b  c
b.outgoing(:friends)  d  e
c.outgoing(:friends)  b
end

If I call on any of those within the same transaction, things work great, but 
if I run that and then open a new transaction to query it, say:

Neo4j::Transaction.run do
a.outgoing(:friends).depth(2).each {|node| puts node[:name]}
end

I get undefined local variable errors for a. I thought that maybe I was missing 
a step where the database committed, but when I tried to switch over to the 
Transaction.new ... Transaction.finish formulation, I started getting 
undefined method errors for 'finish'... I assume I'm missing some basic step, 
but didn't see an answer in the examples/documentation, so I'd appreciate any 
help!
Kristen
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Basic Ruby/Neo4j question

2011-05-11 Thread Peter Neubauer
Vaccaro,
could this be a simple Ruby scoping issue, since you are defining a within
the transaction block? If you move the definition onto a global variable or
declare a outside the block, does it work then?

Cheers,

/peter neubauer

GTalk:  neubauer.peter
Skype   peter.neubauer
Phone   +46 704 106975
LinkedIn   http://www.linkedin.com/in/neubauer
Twitter  http://twitter.com/peterneubauer

http://www.neo4j.org   - Your high performance graph database.
http://startupbootcamp.org/- Ă–resund - Innovation happens HERE.
http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.


On Wed, May 11, 2011 at 10:47 AM, Vaccaro, Kristen M kvacc...@mitre.orgwrote:

 Hi, I just started using Neo4j and I've got a pretty basic question. I've
 been running the gem using JRuby but I'm having trouble calling on
 edges/nodes I've made in previous transactions. So one of the very basic
 example scripts I've been working with looks like:

 require rubygems
 require 'neo4j'
 Neo4j::Transaction.run do
 a = Neo4j::Node.new :name = 'A'
 b = Neo4j::Node.new :name = 'B'
 c = Neo4j::Node.new :name = 'C'
 d = Neo4j::Node.new :name = 'D'
 e = Neo4j::Node.new :name = 'E'
 a.outgoing(:friends)  b  c
 b.outgoing(:friends)  d  e
 c.outgoing(:friends)  b
 end

 If I call on any of those within the same transaction, things work great,
 but if I run that and then open a new transaction to query it, say:

 Neo4j::Transaction.run do
 a.outgoing(:friends).depth(2).each {|node| puts node[:name]}
 end

 I get undefined local variable errors for a. I thought that maybe I was
 missing a step where the database committed, but when I tried to switch over
 to the Transaction.new ... Transaction.finish formulation, I started
 getting undefined method errors for 'finish'... I assume I'm missing some
 basic step, but didn't see an answer in the examples/documentation, so I'd
 appreciate any help!
 Kristen
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user