Add pagination to crops#data_improvement (#4807)

In `CropsController#data_improvement`, paginate `@crops` with
`per_page: 50` so tabs like photos/descriptions do not render all
crops at once. In `data_improvement.html.haml`, render `= will_paginate @crops`.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
Daniel O'Connorandgoogle-labs-jules[bot] authored and GitHub committed 2026-09-20 15:04:14 +09:30
1 parent a3811cf9bd
commit b6270c8d0c
3 files changed
+16 -1

No files matched your search

+1 -1
View File
@@ -174,7 +174,7 @@ class CropsController < ApplicationController
Crop.approved.where(public_food_key: [nil, '']).order(plantings_count: :desc)
else
Crop.none
end
end.paginate(page: params[:page], per_page: 50)
end
private
@@ -11,3 +11,5 @@
.tab-pane.active
%h2= "Crops without #{tabs[@active_tab.to_sym]}"
= render 'crop_list', crops: @crops
= will_paginate @crops
+13
View File
@@ -28,6 +28,19 @@ describe CropsController do
end
end
describe "GET data_improvement" do
context 'wrangler' do
include_context 'login as wrangler'
it 'fetches the data improvement page and paginates crops with per_page 50' do
get :data_improvement
expect(response).to be_successful
expect(response).to render_template("crops/data_improvement")
expect(assigns(:crops).per_page).to eq(50)
end
end
end
describe "GET show" do
let!(:crop) { create(:crop) }
let!(:member) { create(:member) }