2
我有两个型号.. video
和youtube_video
两种不同的模式记录....我有一个index
页面同时显示videos..so我是加入结果集都在一个阵列上显示指数页面,但我得到分页错误..因为undefined method total pages for array
....我做错了什么,,,我知道theres工作,将分页作品ActiveRecord Relation
而不是ActiveRecord
..我甚至尝试model.where ...但犯规的作品......在这个什么解决办法将欣赏:)显示使用分页
我的控制器..
@videos = Video.includes(:user,:reputations,:tags,:comments).paginate(:page =>params[:page], :per_page => 10).order("created_at DESC")
@youtube_videos=YoutubeVideo.includes(:user,:tags).paginate(:page =>params[:page], :per_page => 10).order("created_at DESC")
@all_videos [email protected] + @youtube_videos
我查看文件
###looping on @all_videos....
<div class="page_info text-center" style="margin-bottom:10px">
<!-- it breaks here -->
<%= page_entries_info @all_videos %>
<hr>
<!-- it breaks here too if i remove above line-->
<%= ajax_will_paginate @all_videos %>
</div>
,如果我只使用@videos.
。它的工作原理,但合并与另一model..it breaks..any想法后?
ok ...我得到了我错在哪里..谢谢... @japed – Milind 2014-10-10 13:20:21
你的例子不是很好,添加两个数组都不会将它们排序在彼此之内。在调用.paginate – Alain 2015-03-12 18:34:44
之前,您错过了.sort我刚刚重用了他的代码。你是对的,但我只是回答有关分页错误的问题。 – 2015-03-13 09:18:28