Intense beginner question here but I've been unable to find the answer anywhere.
I have model, show.rb:
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
I create a relationship by which the band is playing the show:
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
I get a response like this:
=> #<Neo4j::Rails::Relationships::NodesDSL:0x39fe9ce1 @dir=:outgoing, @storage=#<Neo4j::Rails::Relationships::Storage:0xcb5efc8 @rel_class=Neo4j::Rails::Relationship, @target_class=Neo4j::Rails::Model, @incoming_rels=[], @node=#<Band:0x3adcbf25 @errors=#<ActiveModel::Errors:0x57f9cc39 @base=#<Band:0x3adcbf25 ...>, @messages={}>, @_relationships={:playing_shows=>#<Neo4j::Rails::Relationships::Storage:0xcb5efc8 ...>}, @_properties={"band_name"=>"MyBand", "_classname"=>"Band"}, @changed_attributes={}, @_create_or_updating=nil, @_java_node=#<Java::OrgNeo4jKernelImplCore::NodeProxy:0x3fd3659b>, @previously_changed={}, @_properties_before_type_cast={:band_name=>"MyBand"}, @validation_context=nil>, @rel_type=:playing_shows, @persisted_related_nodes={:outgoing=>[#<Show:0x50d8dc5a @_relationships={}, @_properties={}, @_java_node=#<Java::OrgNeo4jKernelImplCore::NodeProxy:0x258e4566>, @_properties_before_type_cast={}>]}, @outgoing_rels=[], @persisted_relationships={}, @persisted_node_to_relationships={:outgoing=>{#<Show:0x50d8dc5a @_relationships={}, @_properties={}, @_java_node=#<Java::OrgNeo4jKernelImplCore::NodeProxy:0x258e4566>, @_properties_before_type_cast={}>=>#<Java::OrgNeo4jKernelImplCore::RelationshipProxy:0x349319f9>}}>>
If I do this:
theshow = band.playing_shows.to_a
I get this, which looks more manageable:
=> [#<Show:0x50d8dc5a @_relationships={}, @_properties={"show_name"=>"Test Show"}, @_java_node=#<Java::OrgNeo4jKernelImplCore::NodeProxy:0x258e4566>, @_properties_before_type_cast={}>]
This looks like it is referring to my test show as expected.
but then when try "theshow.show_name" I receive "NoMethodError: undefined method `show_name' for #<Array:0x14eebce6>"
If I try to loop through it like this:
s.show_name
end
I get this:
=> [#<Show:0x50d8dc5a @_relationships={}, @_properties={"show_name"=>"Test Show"}, @_java_node=#<Java::OrgNeo4jKernelImplCore::NodeProxy:0x258e4566>, @_properties_before_type_cast={}>]
How do I get JUST "Test Show" to output? I can't find any sample apps that really show me and I'm too green to make full sense of the documentation. It seems so simple, I'm sure I am doing something wrong.
Any clarification is appreciated.