title: Neo4j Rails 4 how to convert a class to use the GraphDB
body: <p>I'm new to Neo4j and I'm trying to understand how to convert a specific class to this technology. </p>
  
  <p>My Class looks like this:</p>
  
  <pre><code>class Visit &lt; ActiveRecord::Base
  
    belongs_to :study_version
    has_many :elements, :dependent =&gt; :destroy
  
    def self.ordinals(study_version_id)
      visits = Visit.where(study_version_id: study_version_id).order('ordinal asc')
      ordinal = 1
      visits.each do |item|
        item.ordinal = ordinal
        ordinal += 1
        item.save
      end
    end
  
  end 
  </code></pre>
  
  <p>I tried to convert it in this way but was not working good:</p>
  
  <pre><code>class Visit &lt; ActiveRecord::Base
  
    include Neo4j::ActiveNode
    include Neo4j::Timestamps
  
    has_many :out, :element, type: study_version
  
    def self.ordinals(study_version_id)
      visits = Visit.where(study_version_id: study_version_id).order('ordinal asc')
      ordinal = 1
      visits.each do |item|
        item.ordinal = ordinal
        ordinal += 1
        item.save
      end
    end
  
  end
  </code></pre>
  
  <p>I would like to see what I'm doing wrong and what should be the right conversion in this class above. 
  Thanks for help</p>
  
  <pre><code>Element code related to this issue:
  
  class Element
  
      include Neo4j::ActiveNode
      include Neo4j::Timestamps
  
      has_one :out, :study_version, type: :study_version
      has_one :out, :visit, type: :visit
      has_one :out, :form, type: :form
  
      #belongs_to :study_version
      #belongs_to :visit
      #belongs_to :form
  
      def self.find_element(study_version_id, visit_id, form_id)
          elements = Element.where(study_version_id: study_version_id, form_id: form_id, visit_id: visit_id)
          return elements[0] if elements.count &gt; 0
          return nil
      end
  
  end
  </code></pre>