Fix #5293: NoMethodError in sitemap when relation is empty.

This commit is contained in:
evazion
2022-10-14 19:49:21 -05:00
parent 2c3a254359
commit 9c48953e6f
3 changed files with 28 additions and 1 deletions

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<% 0.upto(@relation.maximum(:id) / @limit) do |page| %>
<% 0.upto(@relation.maximum(:id).to_i / @limit) do |page| %>
<% lo = page * @limit %>
<% hi = (page + 1) * @limit %>
<% lastmod = @relation.where(id: lo..hi).maximum(:updated_at)&.iso8601 %>