Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Provides simple macro to define all methods you may potentially need to fully use Rails to_param mechanism.
branch: master

This branch is even with szajbus:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
MIT-LICENSE
README
Rakefile
init.rb

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
Something went wrong with that request. Please try again.