Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.
/ to_param Public archive

Provides simple macro to define all methods you may potentially need to fully use Rails to_param mechanism.

License

Notifications You must be signed in to change notification settings

szajbus/to_param

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Provides simple macro to define all methods you may potentially need to fully use Rails to_param mechanism.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages