首頁

2013年6月6日 星期四

**移動*分頁的型號 / *模版之源****Move pagination out of the model**~

**   **移動*分頁的型號 / *模版之源**
**Move pagination out of the model**~
- The pagination logic is only needed in a single 
action in a single 
    controller, so move it out of the model and into 
that one action. 
  - Because pagination was the only customization 
that stratify-rails 
    made to the Stratify::Activity model, we can 
remove that file from 
    the Rails app altogether. (The core 
implementation of Stratify::Activity 
    remains in the stratify-base gem.)
  - This also restores the desired pagination 
behavior (i.e., 200 per 
    page, as opposed to the default of 25 per page)
 which got borked in 
    commit 4d75b0e. 
 
**Showing 2 changed files with 1 addition and 
7 deletions. Show Diff Stats Hide Diff Stats
  1. 2  stratify-rails/app/controllers\
  2. activities_controller.rb
  3. 6  stratify-rails/app/models/stratify/
  4. activity.rb
2  stratify-rails/app/controllers/
activities_controller.rb
... ... @@ -5,7 +5,7 @@ def index
5 5      # TODO Simplify the logic below once 
this bug is fixed in Kaminari:
6 6      #      https://github.com/amatsuda/
kaminari/issues/145
7 7      activity_criteria = Stratify::Activity.desc(:created_at)
8   -    @activities = Kaminari.paginate_array(activity_criteria).page(params[:page])
  8 +    @activities = Kaminari.paginate_array(activity_criteria).page(params[:page]).per(200)
9 9    end
10 10  
11 11    def destroy
6  stratify-rails/app/models
/stratify/activity.rb
... ... @@ -1,6 +0,0 @@
1   -module Stratify
2   -  class Activity
3   -    include Kaminari::
MongoidExtension::Document
4   -    paginates_per 200
5   -  end
6   -end
 
haha..
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

沒有留言:

張貼留言


if you like make fds, wellcome you here~~anytime***

my free place for everyones who want the good software,

come & download them~ wellcome!!