5
3
mirror of https://github.com/tildeverse/lobsters synced 2024-06-18 06:37:06 +00:00

Use parameterize in title_as_url

Use the Rails feature for this cleanup to catch more corner cases.

Fixes #419
This commit is contained in:
mftaff 2018-01-30 16:14:20 +02:00 committed by Peter Bhat Harkins
parent 14a8b03f86
commit b12e3e908f

View File

@ -676,7 +676,7 @@ class Story < ActiveRecord::Base
wl = 0
words = []
self.title.downcase.gsub(/[,'`\"]/, "").gsub(/[^a-z0-9]/, "_").split("_").
self.title.parameterize.gsub(/[^a-z0-9]/, "_").split("_").
reject{|z| [ "", "a", "an", "and", "but", "in", "of", "or", "that", "the",
"to" ].include?(z) }.each do |w|
if wl + w.length <= max_len