1

Here is my controller:

  def index
    if params[:limit]
      @bisacs = Bisac.order(:bisac_code).page(params[:page]).per(params[:limit])
    else
      @bisacs = Bisac.order(:bisac_code).page(params[:page])
    end
  end

Here is my view:

<%= paginate @bisacs %>
<%= page_entries_info @bisacs %>

The error is:

undefined local variable or method `model' for #<Kaminari::Neo4j::Paginated:0x007ff2f211bf38>

For the line:

<%= page_entries_info @bisacs %>

What I am missing here?

But page_entries_info works when I am using this in the controller for other methods:

q = "
MATCH (b:Bisac)
WITH b, size((b)<-[:INCLUDED_IN]-()) as wokas_count
RETURN b.bisac_code as bisac_code, b.bisac_value as bisac_value, wokas_count, b.uuid as uuid
ORDER BY b.bisac_code
;"
@result = Neo4j::Session.current.query(q).to_a
if params[:limit]
  @result = Kaminari.paginate_array(@result).page(params[:page]).per(params[:limit])
else
  @result = Kaminari.paginate_array(@result).page(params[:page])
end

Here is more info about the error from the log file:

Started GET "/bisacs/d1d614a8-3c70-11e5-8eb8-22000b18b199" for 127.0.0.1 at 2015-08-12 12:49:58 -0400
Processing by BisacsController#show as HTML
  Parameters: {"id"=>"d1d614a8-3c70-11e5-8eb8-22000b18b199"}
 CYPHER 244ms MATCH (result_bisac:`Bisac`) WHERE (result_bisac.uuid = {result_bisac_uuid}) RETURN result_bisac ORDER BY result_bisac.uuid LIMIT {limit_1} | {:result_bisac_uuid=>"d1d614a8-3c70-11e5-8eb8-22000b18b199", :limit_1=>1}
 Bisac#wokas 217ms MATCH bisac24319681 WHERE (ID(bisac24319681) = {ID_bisac24319681}) MATCH bisac24319681<-[rel1:`INCLUDED_IN`]-(result_wokas:`Woka`) RETURN count(result_wokas) AS result_wokas | {:ID_bisac24319681=>24319681}
 Bisac#wokas 216ms MATCH bisac24319681 WHERE (ID(bisac24319681) = {ID_bisac24319681}) MATCH bisac24319681<-[rel1:`INCLUDED_IN`]-(result_wokas:`Woka`) RETURN count(result_wokas) AS result_wokas | {:ID_bisac24319681=>24319681}
  Rendered bisacs/show.html.erb within layouts/application (239.6ms)
Completed 500 Internal Server Error in 707ms

ActionView::Template::Error (undefined local variable or method `model' for #<Kaminari::Neo4j::Paginated:0x007fad5de0ad28>):
    18:   <%= select_tag :limit, options_for_select([5, 10, 15, 20, 25, 30], selected: params[:limit] || 25) %>
    19: <% end %>
    20: <%= paginate @wokas %>
    21: <%= page_entries_info @wokas %>
    22: 
    23: <table>
    24:   <thead>
  app/views/bisacs/show.html.erb:21:in `_app_views_bisacs_show_html_erb___1469171013071285334_70191290534340'


  Rendered /Users/levi/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (5.6ms)
LDB
  • 692
  • 6
  • 18
  • A backtrace would be helpful. It seems like the `page_entries_info` is trying to refer get a `model` off of the `Bisac` scope which Kaminari has wrapped in a `Kaminari::Neo4j::Paginated` class. So maybe it's something that the `kaminari-neo4j` gem hasn't considered yet. – Brian Underwood Aug 12 '15 at 12:17
  • Just edited to provide more clues. – LDB Aug 12 '15 at 14:50
  • I see the query now, but I don't see a backtrace. It would be useful to see where the error is coming from – Brian Underwood Aug 12 '15 at 16:01
  • I edited again to provide more info about the error from the log file. Hope this helps. – LDB Aug 12 '15 at 16:53

2 Answers2

0

Changed the index method to use paginate_array.

  def index
    if params[:limit]
      @bisacs = Kaminari.paginate_array(Bisac.order(:bisac_code).to_a).page(params[:page]).per(params[:limit])
    else
      @bisacs = Kaminari.paginate_array(Bisac.order(:bisac_code).to_a).page(params[:page])
    end
  end

And got the

<%= page_entries_info @bisacs %>

working.

LDB
  • 692
  • 6
  • 18
-1

Ok, so the extra information didn't really get me there, but I tried it myself and was able to reproduce the issue. I think it's an issue in the kaminari-neo4j gem. I've just made a pull request with a fix, but in the meantime can you try changing your Gemfile to this:

gem 'kaminari-neo4j', github: 'cheerfulstoic/kaminari-neo4j'

My forked repository has the fixed. Hopefully megorei / dpisarewski will pull it soon if it seems good and release a gem to rubygems so you can change your Gemfile back

Brian Underwood
  • 10,746
  • 1
  • 22
  • 34
  • The link for the gem is not working. The gem is not installing after I executed an uninstall followed by un install using that link in the Gemfile. Any clue how to make the installation? – LDB Aug 13 '15 at 14:54
  • Did you replace your other `kaminari-neo4j` line? Otherwise, maybe the following? `gem 'kaminary-neo4j', git: 'git@github.com:cheerfulstoic/kaminari-neo4j.git'` – Brian Underwood Aug 13 '15 at 14:59
  • Yes, I replaced that line in the Gem file with the line you provided. No gem install after bundle install and bundle update. – LDB Aug 13 '15 at 15:10
  • Now I am getting this: Fetching git@github.com:cheerfulstoic/kaminari-neo4j.git Warning: Permanently added the RSA host key for IP address '192.30.252.128' to the list of known hosts. Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. – LDB Aug 13 '15 at 17:05
  • If that just started happening then you should try going back to the original `github` option. I think something's weird about the state of your bundler – Brian Underwood Aug 13 '15 at 17:09
  • First I think spelling is wrong here: it should be "kaminari" instead of "kaminary" in the gem name. – LDB Aug 13 '15 at 17:34
  • Third, the error now is: woka-graph levi $ gem install 'kaminari-neo4j', git: 'git@github.com:cheerfulstoic/kaminari-neo4j.git' ERROR: Could not find a valid gem 'kaminari-neo4j,' (>= 0) in any repository ERROR: Possible alternatives: kaminari-neo4j, kaminari-cells, kaminari-i18n, kaminari, kaminari-cache ERROR: Could not find a valid gem 'git:' (>= 0) in any repository ERROR: Possible alternatives: Gitr, git, gita, gith, gitx ERROR: Could not find a valid gem 'git@github.com:cheerfulstoic/kaminari-neo4j.git' (>= 0) in any repository – LDB Aug 13 '15 at 17:36
  • Fourth: I run this above from another computer and another RoR project. I got the same last error as mentioned above. I don't think is the bundler. – LDB Aug 13 '15 at 17:37
  • Ok, maybe the repo isn't in the right format for a gem... I build a gem here: https://www.dropbox.com/s/8ktauc78fcblp6v/kaminari-neo4j-0.0.3.cheerfulstoic.gem?dl=1 which **I think** can be loaded with `gem 'kaminari-neo4j', '0.0.3.cheerfulstoic', path: '/path/to/dir/kaminari-neo4j-0.0.3.cheerfulstoic.gem'` – Brian Underwood Aug 13 '15 at 17:44
  • Ssame error: gem install 'kaminari-neo4j', '0.0.3.cheerfulstoic', path: '/path/to/dir/kaminari-neo4j-0.0.3.cheerfulstoic.gem' ERROR: Could not find a valid gem 'kaminari-neo4j,' (>= 0) in any repository ERROR: Possible alternatives: kaminari-neo4j, kaminari-cells, kaminari-i18n, kaminari, kaminari-cache ERROR: Could not find a valid gem '0.0.3.cheerfulstoic,' (>= 0) in any repository ERROR: Could not find a valid gem 'path:' (>= 0) in any repository ERROR: Possible alte... ERROR: Could not find a valid gem '/path/to/dir/kaminari-neo4j-0.0.3.cheerfulstoic.gem' (>= 0) in any repository – LDB Aug 13 '15 at 17:52