English 中文(简体)
• 原始路线和通道
原标题:will_paginate and nested routes

How do I paginate activities for a given project In my routes file I have

resources :projects do 
 resources :activities
end

在我的活动中,控制者(是否在我的项目控制人中?)

def index
@project = current_user.projects.find(params[:project_id])
@activities = @project.activities.all.paginate(:per_page => 5, :page => params[:page])

respond_to do |format|
  format.html # index.html.erb
  format.xml  { render :xml => @activities }
end
end

我的看法

<%= will_paginate @project.activities %>

然而,没有回过错,但书表中却缺少想象力。 任何想法?

问题回答

首先,我敦促你检查卡米纳里的假肢,因为 will虫似乎已经停止,而且只在铁路3号运输前2号。

https://github.com/amatsuda/kaminari

第二,在您看来,努力做到:

<%= will_paginate @activities %>

你不会与你在你的控制器中创造的变数@活动挂钩。





相关问题
Sort by ranking algorithm using will-paginate

I m creating a digg-like site using Ruby on Rails that ranks the item (based on this algorithm). I m using the will-paginate gem list the items in pages. The problem is, will-paginate only allows me ...

Filtering a Table in Rails

I am working with will_paginate to create a sortable and searchable table. I have got everything to work correctly with the exception of the search box (filter). Right now when I select a different ...

reverse page numbers with will_paginate

Is there any simple way to reverse page numeration with will_paginate? I want for the top page (last time-wise) to be #1, and the last (earliest) to be #N. The reason for that is page contents ...

How to Store and Paginate XML Data as a Rails Model

I have an XML feed I am pulling down and parsing in my Rails app. I started to implement it as a library in lib/ but it seemed more logical to me to treat it as a model. For convenience I am ...

热门标签