I have an index view with 45 products and 3 pages.
I'm using pagy_array like: @pagy, @products = pagy_array(products, items: 20)
If I delete 6 products, I get 39 items on 2 pages. But Google have indexed the third page, and when a customer come on this page, he get an error expected:page in 1..2; got 3
expected:page in 1..2; got 3
How can I compare the params[:page] to the @pagy.page and made a redirect 301 if bigger?
Please check this documentation. You can configure this in the pagy.rb initialiser
https://ddnexus.github.io/pagy/extras/overflow
in the pagy.rb initializer:
require 'pagy/extras/overflow'
# default :empty_page (other options :last_page and :exception )
Pagy::VARS[:overflow] = :last_page
# OR
require 'pagy/countless'
require 'pagy/extras/overflow'
# default :empty_page (other option :exception )
Pagy::VARS[:overflow] = :exception
Other options for handling overflow - :last_page, :empty_page or:exception
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.