Neo4j.rb - # 的未定义局部变量或方法“模型”

Neo4j.rb - undefined local variable or method `model' for #

这是我的控制器:

  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

这是我的观点:

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

错误是:

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

对于行:

<%= page_entries_info @bisacs %>

我在这里缺少什么?

但是当我在控制器中将其用于其他方法时 page_entries_info 有效:

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

以下是有关日志文件中的错误的更多信息:

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)

好的,所以额外的信息并没有真正让我明白,但我自己尝试了一下并且能够重现这个问题。我 认为 这是 kaminari-neo4j gem 中的一个问题。我刚刚提出了一个带有修复的拉取请求,但与此同时你可以尝试将你的 Gemfile 更改为:

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

我的分叉存储库已修复。希望 megorei / dpisarewski 会尽快将它拉下来,如果它看起来不错并发布一个 gem 到 rubygems 这样你就可以把你的 Gemfile 改回来

将索引方法更改为使用 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

并获得了

<%= page_entries_info @bisacs %>

正在工作。