Use rdoc markup in code
This commit is contained in:
parent
150a57d734
commit
c2c7c32ca4
12
README.rdoc
12
README.rdoc
|
@ -91,7 +91,7 @@ Run the following generator command, then edit the generated file.
|
|||
|
||||
* changing +page_method_name+
|
||||
|
||||
You can change the method name `page` to `bonzo` or `plant` or whatever you like, in order to play nice with existing `page` method or association or scope or any other plugin that defines `page` method on your models.
|
||||
You can change the method name +page+ to +bonzo+ or +plant+ or whatever you like, in order to play nice with existing +page+ method or association or scope or any other plugin that defines +page+ method on your models.
|
||||
|
||||
|
||||
=== Configuring default +per_page+ value for each model
|
||||
|
@ -242,22 +242,22 @@ However, the <tt>paginate</tt> helper doesn't automatically handle your Array ob
|
|||
<tt>Kaminari::paginate_array</tt> method converts your Array object into a paginatable Array that accepts <tt>page</tt> method.
|
||||
Kaminari.paginate_array(my_array_object).page(params[:page]).per(10)
|
||||
|
||||
You can specify the `total_count` value through options Hash. This would be helpful when handling an Array-ish object that has a different `count` value from actual `count` such as RSolr search result or when you need to generate a custom pagination. For example:
|
||||
You can specify the +total_count+ value through options Hash. This would be helpful when handling an Array-ish object that has a different +count+ value from actual +count+ such as RSolr search result or when you need to generate a custom pagination. For example:
|
||||
Kaminari.paginate_array([], total_count: 145).page(params[:page]).per(10)
|
||||
|
||||
== Creating friendly URLs and caching
|
||||
|
||||
Because of the `page` parameter and Rails 3 routing, you can easily generate SEO and user-friendly URLs. For any resource you'd like to paginate, just add the following to your `routes.rb`:
|
||||
Because of the +page+ parameter and Rails 3 routing, you can easily generate SEO and user-friendly URLs. For any resource you'd like to paginate, just add the following to your +routes.rb+:
|
||||
|
||||
resources :my_resources do
|
||||
get 'page/:page', :action => :index, :on => :collection
|
||||
end
|
||||
|
||||
This will create URLs like `/my_resources/page/33` instead of `/my_resources?page=33`. This is now a friendly URL, but it also has other added benefits...
|
||||
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]!
|
||||
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]!
|
||||
|
||||
NOTE: In this example, I've pointed the route to my `:index` action. You may have defined a custom pagination action in your controller - you should point `:action => :your_custom_action` instead.
|
||||
NOTE: In this example, I've pointed the route to my <tt>:index</tt> action. You may have defined a custom pagination action in your controller - you should point <tt>:action => :your_custom_action</tt> instead.
|
||||
|
||||
|
||||
== Sinatra/Padrino support
|
||||
|
|
Loading…
Reference in New Issue