I would like to integrate the title string into a URL.
The standard is like:
In view of a good search engine ranking I would like to write the title
of a topic into the URL like:
The problem are special characters like ‘?()&#’ etc. in the title
This is my route thinking:
map.connect ‘:controller/:topictitle’, :controller => ‘topics’, :action
Now I need a revokable solution to turn the title into a suiteable form
without special characters which could make problems.
Here is a function that can do the fitting, but it is not revokable, so
I can’t do the Find command in the Controller (topic =
Topic.find(:first, :conditions => [“title = ?”,
topic_link = topic_link.gsub(/[Ã¤]/, “ae”)
topic_link = topic_link.gsub(/[Ã¼]/, “ue”)
topic_link = topic_link.gsub(/[Ã¶]/, “oe”)
topic_link = topic_link.gsub(" “, “-”)
topic_link = topic_link.gsub(/[(,.?!;:’”)]/, “”)
Is there a better way to do the integration?
Is there a function to convert strings into url suitable forms which can
undo the hole thing afterwards?
Should I commit also the ID?
I would love to here how you do that…