title: Neo4j gem - Query dependant on parameter values
body: <p>This might not be as much neo4j as it is rails. But maybe I'm wrong</p>
  
  <p>I'm looking for suggestions on handling a situation when parameters are specific values. For example. In my query</p>
  
  <pre><code>@friends_events = current_user.friends.events(:e, :rel).where("rel.admin = {admin_p} AND e.size_max &lt; {size_p}", uuid: @event_id, primary_category: params[:primary_category] ).params(admin_p: true, size_p: params[:group_max].to_i)
  </code></pre>
  
  <p>The event has a <code>size_max</code> property which can be an integer or it can be <code>any</code>. Right now I have <code>any</code> as a blank value. Basically if they choose any, I need to ignore that parameter all together in the query (or handle it in a similar fashion). A way to cheat it is to handle the situation outside and if any is selected and the value is blank, I manually set it to a really high number which won't be hit. </p>
  
  <p>Not sure how to do this either inside or outside the query without an odd hacky way right now. Suggestions?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I have my query as you suggested. and the methods to deal with the 'validation'</p>
  
  <pre><code>@friends_events = current_user.friends.events(:e, :rel).where("rel.admin = {admin_p} #{size_string}", uuid: @event_id, primary_category: params[:primary_category] ).params(admin_p: true, size_p: size_param)
  </code></pre>
  
  <p>And I changed the <code>size_param</code> to blank which it doesn't like. I wanted to be able to handle both cases. e.g. when you first hit the page params is empty, and when you submit, it's blank. Nil will work with scenario 1 and not scenario 2. Do I need a <code>||</code> case here?</p>
  
  <pre><code>        def size_string
            'AND e.size_max &lt; {size_p}' if params[:group_max]
          end
  
          def size_param
              #has not taken in blank scenario
            params[:group_max].blank? ? false : params[:group_max].to_i
          end
  </code></pre>
  
  <p>and in my view I have</p>
  
  <p><code>&lt;% if !@friends_events.blank? %&gt;</code></p>
  
  <p>My error is </p>
  
  <p><code>Don't know how to compare that. Left: 0 (Long); Right: false (Boolean)</code> from the line above in my view. Changing <code>.blank?</code> to <code>.nil?</code> allows the filter to go through (though incorrectly)</p>