Skip to content

Query::Builder#first and last break pagination parameters #292

Closed
@gaorlov

Description

@gaorlov

Example:

scope = Example::User.where( name: "Greg" )
scope.first

# scope is set to
#<JsonApiClient::Query::Builder:0x000055dafec45c50 @klass=Example::Client::User, @primary_key=nil, @pagination_params={"page"=>1, "per_page"=>1}, @path_params={}, @additional_params={}, @filters={:name=>"Greg"}, @includes=[], @orders=[], @fields=[], @to_a=[#<Example::Client::User:@attributes={"type"=>"users", "id"=>1, "name"=>"Greg"}>]>

scope.all
# will call find on whatever is already there and only return the first record

scope.paginate( page: 10, :per_page: 100).first
# will eat all the pagination params and return only the first record

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions