mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
Merge pull request #1067 from phylor/features/next_page_path-format-option
Add support for `format` option in `next_page_path`
This commit is contained in:
commit
9623197dfd
2 changed files with 12 additions and 1 deletions
|
@ -258,7 +258,7 @@ This would modify the query parameter name on each links.
|
|||
### Extra Parameters (`:params`) for the Links
|
||||
|
||||
```erb
|
||||
<%= paginate @users, params: {controller: 'foo', action: 'bar'} %>
|
||||
<%= paginate @users, params: {controller: 'foo', action: 'bar', format: :turbo_stream} %>
|
||||
```
|
||||
|
||||
This would modify each link's `url_option`. :`controller` and :`action` might be the keys in common.
|
||||
|
@ -288,6 +288,12 @@ This option makes it easier to do things like A/B testing pagination templates/t
|
|||
|
||||
This simply renders a link to the next page. This would be helpful for creating a Twitter-like pagination feature.
|
||||
|
||||
The helper methods support a `params` option to further specify the link. If `format` needs to be set, inlude it in the `params` hash.
|
||||
|
||||
```erb
|
||||
<%= link_to_next_page @items, 'Next Page', params: {controller: 'foo', action: 'bar', format: :turbo_stream} %>
|
||||
```
|
||||
|
||||
### The `page_entries_info` Helper Method
|
||||
|
||||
```erb
|
||||
|
|
|
@ -526,6 +526,11 @@ if defined?(::Rails::Railtie) && defined?(::ActionView)
|
|||
users = User.page(2).per(1)
|
||||
assert_nil view.path_to_next_page(users, params: {controller: 'users', action: 'index'})
|
||||
end
|
||||
|
||||
test 'format option' do
|
||||
users = User.page(1).per(1)
|
||||
assert_equal '/users.turbo_stream?page=2', view.path_to_next_page(users, params: {controller: 'users', action: 'index', format: :turbo_stream})
|
||||
end
|
||||
end
|
||||
|
||||
sub_test_case '#path_to_prev_page' do
|
||||
|
|
Loading…
Reference in a new issue