Browse the Ruby on Rails Community.

You are here: Browse Railsplugins Acts As Friendly Param

Acts As Friendly Param

  1. acts_as_friendly_param #
  2. blutak’d together by chrisfarms # # #
  3. Use this act if you want your models to use more descriptive :id fields in URLs
  4. A model using acts_as_friendly_param may have a RESTful URL such as: #
  5. /posts/4-the-day-the-earth-stood-still #
  6. Its a VERY SIMPLE extension … but since I keep writing it I thought
  7. it should be pluginified #
  8. thanks to Mephisto for the iconv character translation code
  9. and thanks to Obie Fernandez for blogging about overiding #to_param # # # # #
  10. Note about strict URLs #
  11. if you have to do any SEO work you will find that many search
  12. engines will penalize you for having multiple URLs pointing to the same
  13. page/resource. #
  14. for this reason acts_as_friendly_param raises a ActiveRecord::RecordMoved
  15. if the ID in the url matches but the text string doesn’t #
  16. this should give you a chance to catch the error and perform a 301 HTTP
  17. redirect to the correct resource.
  18. if you do not want this feature disable it like so: #
  19. acts_as_friendly_param :name, :strict => false # #

NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly