Skip to content

Instantly share code, notes, and snippets.

@andreasronge
Created April 22, 2013 07:34
Show Gist options
  • Save andreasronge/5433066 to your computer and use it in GitHub Desktop.
Save andreasronge/5433066 to your computer and use it in GitHub Desktop.
Working with relstionships
require 'neo4j'
class Show < Neo4j::Rails::Model
property :show_name, type: String, index: :exact
has_n :booked_bands
end
#I have another model, band.rb
class Band < Neo4j::Rails::Model
property :band_name, type: String, index: :exact
has_n :playing_shows
end
#I create a show.
show = Show.new
show.show_name = "Test Show"
show.save
#I create a band.
band = Band.new
band.band_name = "MyBand"
band.save
puts "Done"
band.playing_shows << show
band.save
# The crux of my question: how do I access the band object's properties when I retrieve it from the show?
# Whenever I try to do something like this:
theshow = band.playing_shows.first
puts "The Band #{band.band_name} will show #{theshow.show_name}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment