Skip to content

Commit

Permalink
Add example for friendly URLs with concern in README
Browse files Browse the repository at this point in the history
Thanks to @IngusSkaistkalns for his suggestion. closes kaminari#588
  • Loading branch information
yuki24 committed Aug 19, 2014
1 parent 5f9b795 commit 5d4eba8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.rdoc
Expand Up @@ -271,6 +271,14 @@ Because of the +page+ parameter and Rails 3 routing, you can easily generate SEO
get 'page/:page', :action => :index, :on => :collection
end

If you are using Rails 4 or later, you can simplify route definitions by using `concern`:

concern :paginatable do
get '(page/:page)', :action => :index, :on => :collection, :as => ''
end

resources :my_resources, :concerns => :paginatable

This will create URLs like <tt>/my_resources/page/33</tt> instead of <tt>/my_resources?page=33</tt>. This is now a friendly URL, but it also has other added benefits...

Because the +page+ parameter is now a URL segment, we can leverage on Rails page caching[http://guides.rubyonrails.org/caching_with_rails.html#page-caching]!
Expand Down

0 comments on commit 5d4eba8

Please sign in to comment.