kaminari友好的URL和rails网址

时间:2014-01-20 12:15:47

标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.2 kaminari

courses_path

此路径生成网址:

http://localhost:3000/courses

友好的网址:

resources :courses, :only => [:index] do
  get 'page/:page', :action => :index, :on => :collection
end

当我想要paginate很多课程时,网址输出类似于:

http://localhost:3000/courses/page/2
http://localhost:3000/courses/page/3
http://localhost:3000/courses/page/4
.
.
.

对于第一页,网址为courses_pathcourses_url

http://localhost:3000/courses

kaminari生成的每个页面的链接助手是什么?

1 个答案:

答案 0 :(得分:2)

您可以尝试以下配置:

get '/courses(/page/:page)' => 'courses#index', :as => :courses, :page => 1