Home > fancy_string

fancy_string

Fancy_string is a project mainly written in Ruby, based on the MIT license.

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

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

    My first article

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

Previous:netspire-oracle