diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 8af3a8d..f133e7b 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -30,7 +30,12 @@ class GroupsController < ApplicationController def index respond_to do |format| format.html { - @groups = Group.sorted.to_a + scope = Group.sorted + scope = scope.like(params[:name]) if params[:name].present? + + @group_count = scope.count + @group_pages = Paginator.new @group_count, per_page_option, params['page'] + @groups = scope.limit(@group_pages.per_page).offset(@group_pages.offset).to_a @user_count_by_group_id = user_count_by_group_id } format.api { diff --git a/app/views/groups/index.html.erb b/app/views/groups/index.html.erb index 888b408..95a683e 100644 --- a/app/views/groups/index.html.erb +++ b/app/views/groups/index.html.erb @@ -4,6 +4,7 @@ <%= title l(:label_group_plural) %> <% if @groups.any? %> +
@@ -20,6 +21,8 @@ <% end %>
<%=l(:label_group)%>
+
+<%= pagination_links_full @group_pages, @group_count %> <% else %>

<%= l(:label_no_data) %>

<% end %>