FIX: proper regex for category slug validation

This commit is contained in:
Arpit Jalan 2016-01-07 12:06:45 +05:30
parent dcd0270d52
commit bfd21461df

View File

@ -230,7 +230,7 @@ SQL
end
# only allow to use category itself id. new_record doesn't have a id.
unless new_record?
match_id = /(\d+)-category/.match(self.slug)
match_id = /^(\d+)-category/.match(self.slug)
errors.add(:slug, :invalid) if match_id && match_id[1] && match_id[1] != self.id.to_s
end
end