Skip to content

Commit c8e5d7e

Browse files
committed
fix route errors, remove duplicate pagination gems
1 parent 2b94d6e commit c8e5d7e

File tree

13 files changed

+20
-30
lines changed

13 files changed

+20
-30
lines changed

ADMIN_INTERFACE.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,10 @@ module Admin
244244
before_action :set_item, only: [:show, :edit, :update, :destroy]
245245

246246
def index
247-
@items = YourModel.includes(:associations)
248-
.page(params[:page])
249-
.per(25)
247+
@pagy, @items = pagy(
248+
YourModel.includes(:associations),
249+
items: 25
250+
)
250251
end
251252

252253
def new

CONTRIBUTING.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,11 @@ class StreamsController < ApplicationController
174174
before_action :set_stream, only: %i[show update destroy]
175175

176176
def index
177-
@streams = policy_scope(Stream)
178-
.includes(:streamer, :user)
179-
.filter_by(filter_params)
180-
.page(params[:page])
177+
@pagy, @streams = pagy(
178+
policy_scope(Stream)
179+
.includes(:streamer, :user)
180+
.filter_by(filter_params)
181+
)
181182
end
182183

183184
private

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ gem "pundit", "~> 2.3"
6262
gem "rack-attack", "~> 6.7"
6363

6464
# Pagination
65-
gem "kaminari", "~> 1.2"
6665
gem "pagy", "~> 6.2"
6766

6867
# Serialization

Gemfile.lock

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,6 @@ GEM
179179
jsonapi-renderer (0.2.2)
180180
jwt (2.10.1)
181181
base64
182-
kaminari (1.2.2)
183-
activesupport (>= 4.1.0)
184-
kaminari-actionview (= 1.2.2)
185-
kaminari-activerecord (= 1.2.2)
186-
kaminari-core (= 1.2.2)
187-
kaminari-actionview (1.2.2)
188-
actionview
189-
kaminari-core (= 1.2.2)
190-
kaminari-activerecord (1.2.2)
191-
activerecord
192-
kaminari-core (= 1.2.2)
193-
kaminari-core (1.2.2)
194182
language_server-protocol (3.17.0.5)
195183
lint_roller (1.1.0)
196184
logger (1.7.0)
@@ -446,7 +434,6 @@ DEPENDENCIES
446434
jbuilder
447435
jsbundling-rails
448436
jwt
449-
kaminari (~> 1.2)
450437
lograge (~> 0.14)
451438
pagy (~> 6.2)
452439
pg (~> 1.1)

RAILS_SETUP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ The StreamSource Rails 8 application includes:
9999
- **Rate Limiting**: Rack::Attack configuration
100100
- **CORS**: Rack::Cors for API access control
101101
- **Caching**: Redis integration
102-
- **Pagination**: Pagy for admin, Kaminari available
102+
- **Pagination**: Pagy for all pagination needs
103103
- **N+1 Detection**: Bullet in development
104104
- **Logging**: Lograge for structured logs
105105

app/controllers/admin/ignore_lists_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def index
1919
@ignore_lists = @ignore_lists.order(created_at: :desc)
2020

2121
# Pagination
22-
@ignore_lists = @ignore_lists.page(params[:page]).per(25)
22+
@pagy, @ignore_lists = pagy(@ignore_lists, items: 25)
2323

2424
respond_to do |format|
2525
format.html

app/controllers/api/v1/base_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def paginate(collection)
1717
offset = (page - 1) * per_page
1818
paginated = collection.offset(offset).limit(per_page)
1919

20-
# Add singleton methods for Kaminari compatibility
20+
# Add singleton methods for pagination metadata
2121
paginated.define_singleton_method(:current_page) { page }
2222
paginated.define_singleton_method(:limit_value) { per_page }
2323
paginated.define_singleton_method(:total_count) { collection.count }

app/controllers/api/v1/ignore_lists_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def index
2020
end
2121

2222
# Pagination
23-
@ignore_lists = @ignore_lists.page(params[:page]).per(params[:per_page] || 100)
23+
@ignore_lists = paginate(@ignore_lists)
2424

2525
render json: {
2626
ignore_lists: @ignore_lists.as_json,

app/helpers/application_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
module ApplicationHelper
2+
include Pagy::Frontend
3+
24
def user_color(user)
35
colors = ["#FF6B6B", "#4ECDC4", "#45B7D1", "#FFA07A", "#98D8C8", "#F7DC6F", "#BB8FCE", "#85C1E2"]
46
colors[user.id % colors.length]

app/views/admin/ignore_lists/index.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@
9797
<% end %>
9898

9999
<!-- Pagination -->
100-
<% if @ignore_lists.total_pages > 1 %>
100+
<% if @pagy.pages > 1 %>
101101
<div class="bg-gray-50 dark:bg-gray-900 px-6 py-3">
102-
<%= paginate @ignore_lists, theme: 'tailwind' %>
102+
<%== pagy_bootstrap_nav(@pagy) %>
103103
</div>
104104
<% end %>
105105
</div>

0 commit comments

Comments
 (0)