Skip to content

Commit

Permalink
Present of a paginated collection, vs. a paginated array.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Jun 1, 2015
1 parent cb67ef3 commit 57e492b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ GEM
loofah (~> 2.0)
rainbow (2.0.0)
rake (10.4.2)
representable (2.2.0)
representable (2.2.2)
multi_json
nokogiri
uber (~> 0.0.7)
Expand Down
2 changes: 1 addition & 1 deletion app/api/endpoints/challenges_endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ChallengesEndpoint < Grape::API
optional :size, type: Integer, default: 3, desc: 'Number of challenges to return.'
end
get do
present Kaminari.paginate_array(Challenge.all).page(params[:page]).per(params[:size]), with: Api::Presenters::ChallengesPresenter
present Challenge.all.page(params[:page]).per(params[:size]), with: Api::Presenters::ChallengesPresenter
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/api/endpoints/matches_endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MatchesEndpoint < Grape::API
optional :size, type: Integer, default: 3, desc: 'Number of matches to return.'
end
get do
present Kaminari.paginate_array(Match.all).page(params[:page]).per(params[:size]), with: Api::Presenters::MatchesPresenter
present Match.all.page(params[:page]).per(params[:size]), with: Api::Presenters::MatchesPresenter
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/api/endpoints/users_endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class UsersEndpoint < Grape::API
optional :size, type: Integer, default: 3, desc: 'Number of users to return.'
end
get do
present Kaminari.paginate_array(User.all).page(params[:page]).per(params[:size]), with: Api::Presenters::UsersPresenter
present User.all.page(params[:page]).per(params[:size]), with: Api::Presenters::UsersPresenter
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions config/initializers/mongoid/criteria.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Mongoid
class Criteria
def respond_to?(method, include_private = false)
# see https://github.com/intridea/grape/blob/master/lib/grape/dsl/inside_route.rb#L209, causes a merge without options
method == 'merge' ? false : super
end
end
end

0 comments on commit 57e492b

Please sign in to comment.