[PLUGIN RELEASE] ActsAsSeoFriendly
ActsAsSeoFriendly
== DESCRIPTION:
Create an SEO friendly field for a model automatically based on a given field.
So if you have a Blogs model, and you would like create an SEO friendly version
of the 'title' field, you would just add this to your model and then be able to
use the SEO friendly id as the unique id to the resource. The plugin will only
append an integer to the SEO id if there is a collision.
== SYNOPSIS:
Create seo column migration:
class CreateSeoTestModels < ActiveRecord::Migration
def self.up
create_table :seo_test_models do |t|
t.string :name
t.timestamps
end
SeoTestModel.create_seo_friendly_column()
end
def self.down
SeoTestModel.drop_seo_friendly_column()
drop_table :seo_test_models
end
end
Add to model:
class SeoTestModel < ActiveRecord::Base
acts_as_seo_friendly :resource_id => :name,
:seo_friendly_id_field => :seo_id, # default is :seo_friendly_id
:seo_friendly_id_limit => 100 # default is 50
end
To lookup the resource in the controllers use:
SeoTestModel.find_by_seo_id(params[:id])
== INSTALL:
sudo gem install revolutionhealth-acts_as_seo_friendly -s http://gems.github.com
== SOURCE:
http://github.com/revolutionhealth/acts_as_seo_friendly/tree/master
To see the plugin in action see our recipes section, for example:
http://www.revolutionhealth.com/recipes/thai-miang-khem-style-salad
== FEATURES/PROBLEMS:
* Only tested on mysql and sqlite3
5 comments:
After inspecting the code, it appears your solution has existed for over a year in the form of permalink_fu. Looks like revolution has successfully reinvented the wheel again. Or something like that...
Hi..
......
SeoTestModel.create_seo_friendly_column()
end
When I the run the migration I get:
rake aborted!
undefined method `create_seo_friendly_column' for
...
I use Rails 2.10
What to do?
Regards Werner
Hey Jefferey, I'm just trying out this plugin but I think you're missing something for the setup. You say to gem install and then add the acts_as_ in your model but rails doesn't know that method, probably because there was no plugin installed. After installing the gem do I need to unpack it in vendor/plugins?
anonymous: actually we combined several plugins that had various parts of functionality. We also optimized the queries, where plugins like permalink_fu iterate over the database, we determine the index in a single query.
werner & jd, i was assuming you would put the:
gem 'acts_as_seo_friendly'
require 'acts_as_seo_friendly'
or on 2.1:
config.gem 'revolutionhealth-acts_as_seo_friendly', :lib => 'acts_as_seo_friendly'
Post a Comment