If you are building a social Rails application, or any other Rails application that needs to have a URL slug, rather than the typical users/admin/232 type of URL scheme, then the acts_as_slugable plugin is going to be a perfect fit.

In my current Rails project, I want the users to be have their own “storefront” per se. Using acts_as_slugable, I can now have my URL scheme go from

http://www.example.com/users/145

to something like this

http://www.example.com/users/cory-perry

Much better for SEO, linking, and just overall a better URL in general.

Acts_as_slugable generates the URL slug based on a specific field that you specify, making it fairly easy to create URL slugs customized to your specific app needs. This is an extremely helpful plugin!

To install this plugin into your Rails app, execute this code from your command line:

./script/plugin install http://code.dunae.ca/acts_as_slugable

Share and Enjoy:
  • Digg
  • Technorati
  • del.icio.us
  • StumbleUpon
  • NewsVine


  • RELATED / YOU MIGHT FIND THESE INTERESTING
  • No related posts




COMMENTS / 2 COMMENTS

You may be interested in permalink_fu, it’s been used in a lot of projects and supports a few more options than yours: http://github.com/technoweenie/permalink_fu/tree/master/lib/permalink_fu.rb

rick added these pithy words on Sep 20 08 at 5:31 pm

Thanks Rick, I’ll check it out!

Cory added these pithy words on Sep 21 08 at 9:13 am


SPEAK / ADD YOUR COMMENT
Comments are moderated.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Return to Top