Skip to content

Commit

Permalink
fix using symbol as param_name that raise an error in params_for (#1121)
Browse files Browse the repository at this point in the history
* fix using symbol as param_name that raise an error in params_for
* test added for param_name as symbol
  • Loading branch information
magnum committed Mar 19, 2024
1 parent b3075db commit 5438e08
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kaminari-core/lib/kaminari/helpers/tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def page_url_for(page)
private

def params_for(page)
if (@param_name == :page) || !@param_name.include?('[')
if (@param_name == :page) || !@param_name.to_s.include?('[')
page_val = !Kaminari.config.params_on_first_page && (page <= 1) ? nil : page
@params[@param_name] = page_val
@params
Expand Down
6 changes: 6 additions & 0 deletions kaminari-core/test/helpers/tags_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ class TagTest < ActionView::TestCase
assert_match(/foo\.page=\d+/, Kaminari::Helpers::Tag.new(self, param_name: 'foo.page').page_url_for(2))
end
end

sub_test_case "with param_name = :symbol_param option" do
test 'using a symbol as param_name' do
assert_match(/symbol_param=\d+/, Kaminari::Helpers::Tag.new(self, param_name: :symbol_param).page_url_for(2))
end
end
end
end

Expand Down

0 comments on commit 5438e08

Please sign in to comment.