Errata
Page 48 (Chapter 6)#
Reference: chapter06/app/models/page.rb#L19
The make_slug method is missing an early return guard clause. This is needed for when the title is nil. It should
be:
def make_slug
return unless title
self.slug = title
.downcase
.gsub(/[_ ]/, '-')
.gsub(/[^-a-z0-9+]/, '')
.gsub(/-{2,}/, '-')
.gsub(/^-/, '')
.chomp('-')
end
Reported on 2023-12-31 by Hiroaki Satou