szajbus / to_param
- Source
- Commits
- Network (2)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
to_param /
README
ToParam
=======
ToParam plugin provides simple macro to define all methods you may potentially need to fully use to_param mechanism.
Intended but not limited to work with Ruby on Rails and ActiveRecord.
Installation
============
script/plugin install git://github.com/szajbus/to_param.git
Example
=======
class Article < Active::Record
to_param :slug
end
The code above is equivalent to:
class Article < Active::Record
def to_param
slug
end
def self.find_by_param(*args)
find_by_slug(args)
end
def self.find_by_param!(*args)
find_by_slug!(args)
end
def self.find_all_by_param(*args)
find_all_by_slug(args)
end
def self.find_all_by_param!(*args)
find_all_by_slug!(args)
end
end
So this plugin is just a time-and-space-saver, not much magic here.
Copyright (c) 2009 MichaĆ Szajbe, released under the MIT license

