Skip to content

Commit

Permalink
Refactor pagy call so we don't need to override the method
Browse files Browse the repository at this point in the history
  • Loading branch information
excid3 committed Feb 27, 2025
1 parent eb6fdf4 commit f16dc1a
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions lib/madmin/fields/has_many.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,7 @@ def paginateable?
end

def paginated_value(record, params)
pagy value(record), params: params, page_param: "#{attribute_name}_page"
end

# Override to access params from vars since we're not in a controller/view
def pagy_get_page(vars, force_integer: true)
params = vars[:params]
page = params[vars[:page_param] || DEFAULT[:page_param]]
force_integer ? (page || 1).to_i : page
pagy value(record), page: params.fetch("#{attribute_name}_page", 1), page_param: "#{attribute_name}_page"
end
end
end
Expand Down

0 comments on commit f16dc1a

Please sign in to comment.