7
月分页我想分页按月职位,我在Post模型与雷
class Post
include Mongoid::Document
include Mongoid::Timestamps
scope :by_month, lambda {|end_date| Post.order_by(:created_at => :asc).where(:created_at.gte => (end_date.to_date.beginning_of_month), :created_at.lte => (end_date.to_date))}
end
添加下列范围在我的控制,我把
def show
@posts = Post.by_month(Time.now).page(params[:page]).per(20)
end
鉴于
<%= paginate @posts, :theme => 'month_theme' %>
<%= render @posts %>
问题:
- 分页不按月工作,我想在一个页面中显示一个月的所有结果,通过params [:month] = 2或params [:month] = Feb取代params [:page]
- 我认为“2011年8月”,而不是1,2
- 环月和今年一样,当你转到前面,而在“2011年1月”,它会转到“2010年12月”