I have friendly_id
setup properly and everything works, using slugs.
The issue I am having is that some of the names on my Tag
model (which is the model that FriendlyId is attached to) need to be HTML escaped.
Names like c++
or .net
.
When I ran Tag.find_each(:&save)
, it generated all the slugs for me....but on those tags with those names, this is what happened:
> c = Tag.where(:name => "c++")
Tag Load (0.9ms) SELECT "tags".* FROM "tags" WHERE "tags"."name" = 'c++'
=> [#<Tag id: 2, name: "c++", num_questions: 187598, created_at: "2013-03-23 07:02:09", updated_at: "2013-03-29 15:34:09", questions_count: 87, slug: "c">]
> Tag.where(:name => ".net")
Tag Load (0.9ms) SELECT "tags".* FROM "tags" WHERE "tags"."name" = '.net'
=> [#<Tag id: 142, name: ".net", num_questions: 149074, created_at: "2013-03-23 07:09:47", updated_at: "2013-03-29 15:34:10", questions_count: 85, slug: "net">]
1.9.3p392 :012 > Tag.where(:name => "c#")
Tag Load (1.0ms) SELECT "tags".* FROM "tags" WHERE "tags"."name" = 'c#'
=> [#<Tag id: 38, name: "c#", num_questions: 435620, created_at: "2013-03-23 07:03:27", updated_at: "2013-03-29 15:34:10", questions_count: 130, slug: "c--3">]
Notice the slugs on each of those - and how they don't correspond properly to the name
of each record.
How do I fix this?