这是我的控制器:
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)
答案 0 :(得分:0)
更改索引方法以使用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 %>
的工作。
答案 1 :(得分:-1)
好的,所以额外的信息并没有真正让我在那里,但我自己尝试了并且能够重现这个问题。我认为这是kaminari-neo4j
gem中的一个问题。我刚刚发布了一个带有修复的pull请求,但在此期间你可以尝试将你的Gemfile更改为:
gem 'kaminari-neo4j', github: 'cheerfulstoic/kaminari-neo4j'
我的分叉存储库已修复。希望megorei / dpisarewski如果看起来好的话会尽快拉出它并将rubygems发布给宝石以便你可以更改你的Gemfile