Plugins - seo_urls
Add to favoritesseo_urls
Installation:
script/plugin install http://svn.redshiftmedia.com/svn/plugins/seo_urls
Usage:
To apply this plugin to a model:
class Post < ActiveRecord::Base
seo_urls
end
Or to use an attribute other than name or title:
class Post < ActiveRecord::Base
seo_urls "nickname"
end
Information
The plugin looks for ‘name’ or ‘title’ attributes and if they are available it uses them to generate a search engine friendly string. to_param method is overwritten so that it returns the the numerical id of the record with the search engine friendly string appended to it.
An example model @post=>{:id=>12,:title=>"seo_urls rails plugin"}
Without the plugin: post_url(@post)=>"/posts/show/12"
With the plugin: post_url(@post)=>"/posts/show/12-seo-urls-rails-plugin"
If the value of the attribute being used to create the url string for a particular model changes, so will the resulting url string. However, old urls (which might have been stored in bookmarks etc.) will still work because rails only pays attention to the id reference number that begins the :id portion of any url, ignoring anything that follows it.
Resources
Subversion
Author
- Tomasz Kaye. info [at] redshiftmedia [dot] com
http://www.bitbutter.com/seo_urls-plugin-making-show-pages-more-findable/14
http://svn.redshiftmedia.com/svn/plugins/seo_urls
Rails' (MIT)
Model


FYI: This plugin can result in multiple URLs pointing to the same content such that there's no single permalink. This situation can be bad for SEO.
I suggest that your controller should check the url used for inbound access and send a 301 redirect if it's not the current one.
Also, SEO is better if you don't have an ID at the front of the URL, I recommend actsas_urlparam if you're looking for the best SEO possible.
Cool.
I rearranged the else statement to allow a function to be used as well to generate the name if the passed string isn't an attribute...
elsif self.respondto? attributeforurl.tosym string=self.send(attributeforurl)
At the time of writing the short install command isn't working, so please use:
script/plugin install http://svn.redshiftmedia.com/svn/plugins/seo_urls