remove non-alphanumeric chars from item pretty urls
mainly because they were causing the router to freak out when they contained periods, because that looks like a format, e.g. show.html
This commit is contained in:
parent
fa46a03c91
commit
183430adb6
2 changed files with 3 additions and 2 deletions
|
@ -156,8 +156,9 @@ class Item < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
URL_CHAR_BLACKLIST = /[^a-z0-9\-]/i
|
||||||
def name_for_url
|
def name_for_url
|
||||||
name.downcase.gsub(' ', '-')
|
name.downcase.gsub(' ', '-').gsub(URL_CHAR_BLACKLIST, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_param
|
def to_param
|
||||||
|
|
|
@ -126,7 +126,7 @@ function Wardrobe() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNameForSlug() {
|
function getNameForSlug() {
|
||||||
return item.name.toLowerCase().replace(/ /g, '-');
|
return item.name.toLowerCase().replace(/ /g, '-').replace(/[^a-z0-9\-]/i, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSlug() {
|
function getSlug() {
|
||||||
|
|
Loading…
Reference in a new issue