Add group filtering by name for API

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2014-12-30 11:30:56 +02:00
parent da9d827904
commit 2660e83c97
2 changed files with 10 additions and 5 deletions

View File

@ -19,6 +19,8 @@ GET /groups
] ]
``` ```
You can search for groups by name or path with: `/groups?search=Rails`
## Details of a group ## Details of a group
Get all details of a group. Get all details of a group.

View File

@ -25,11 +25,14 @@ module API
# Example Request: # Example Request:
# GET /groups # GET /groups
get do get do
if current_user.admin @groups = if current_user.admin
@groups = paginate Group Group.all
else else
@groups = paginate current_user.groups current_user.groups
end end
@groups = @groups.search(params[:search]) if params[:search].present?
@groups = paginate @groups
present @groups, with: Entities::Group present @groups, with: Entities::Group
end end