neo4jrb / neo4j-will_paginate_redux

Integrate neo4j and will_paginate
6 stars 4 forks source link

undefined method `paginate' despite 'neo4j-will_paginate_redux' is required #5

Open im-13 opened 9 years ago

im-13 commented 9 years ago

Could you please explain why I get undefined method `paginate' error? The gem is required in the rb file:

require 'neo4j-will_paginate_redux' class MatchesController < ApplicationController def create [some code] @matches = User.query_as(:n).match("n-[:lives_in]->(country:Country)").where("country.name = '#{target_country.name}' AND n.email <> '#{username}'").pluck(:n).paginate(:page => params[:page], :per_page => 10, order: :first_name) [some code]

subvertallchris commented 9 years ago

Two issues:

As soon as you call pluck, you return records from the database and are working with an enumerable. not any kind of query object, so pagination isn't possible.

Second, paginate is a method on the QueryProxy class but as soon as you call query_as, you are working in Neo4j-core's Query class, which powers QueryProxy. There's an article about the classes at http://neo4jrb.io/blog/2015/02/08/query_or_query-proxy.html.

jessmartin commented 8 years ago

@subvertallchris Any chance we might see this extended to work for a general Query? My query has passed beyond the ability of QueryProxy's mighty lil' query builder...

subvertallchris commented 8 years ago

We could rework this gem and the Paginated class. Paginated mostly uses methods that are from or available in Neo4j::Core::Query, so we could refactor it to provide interfaces in both that class and QueryProxy. I'd probably need a hand with it, though. A little short on time at the moment.

jessmartin commented 8 years ago

@subvertallchris ...and I just discovered proxy_as... I'll probably just use that to transform my result back into a QueryProxy and then call .paginate from there. That seems like it would work to me.