简体   繁体   中英

How to change a parameter in kaminari pagination - Ruby On Rails

My pagination works like;

/questions/meals/fish?page=1

I would like to modify the second parameter of this URL like:

/questions/deserts/fish?page=1

How can I change the second parameter? (preferably without modifying the routes.rb file)

In the kaminari paginate helper method you can override the controller and action

paginate @users, params: {controller: 'foo', action: 'bar'} 

So in your case...

paginate @fishes, params: {controller: 'desserts', action: 'fish'}

Note that it has to be a valid route in your routes.rb or when the link is clicked, the app won't accept the path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM