/fancy_string

Simple convert from "My favorite café" to "my-favorite-cafe". Removes diacritics. Useful for SEO url.

Primary LanguageRubyMIT LicenseMIT

FancyString
===========

You can simple convert from "My favorite café" to "my-favorite-cafe"

SEO url? Yes. You can get url like "/articles/1/my-first-article" instead of "/articles/1"

Fancy_string extends standard String class.


Example
=======

str = "My COOL fancy string"
str.fancy
# => "my-cool-fancy-string"


Real example
============

We have an article controller.

1. Add this route, to allow additional parameter *fancy
   
    map.article 'article/:id/*fancy', :controller => 'article', :action => 'show'

2. Then use link_to helper like this:

    # Controller
    @article = Article.find(params[:id])

    # View
    <%= link_to @article.title, article_path(@article, @article.title.fancy)

    # output
    <a href="/article/1/my-first-article">My first article</a>


Copyright (c) 2010 Stefan Huska, released under the MIT license