Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

acts as param

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 tasks
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README
Octocat-spinner-32 Rakefile
Octocat-spinner-32 acts_as_param.gemspec
README
ActsAsParam
===========

Example
=======

// In you model
class Product
  acts_as_param :name, :serial
end

// How To Use
product = Product.create(:name => 'name',:serial => 'serial'}
product.to_param == 'name'

product = Product.create(:name => nil,:serial => 'serial'}
product.to_param == 'serial'

product = Product.create(:name => nil,:serial => nil}
product.to_param == product.id

product.find_by_param('serial') # find by product's serial
product.find_by_param('name')   # find by product's name
product.find_by_param(2)        # find by Product's primary key

product.find_by_param!('serial') # raise ActiveRecord::RecordNotFound exception if not found


Copyright (c) 2010 Jinzhu / wosmvp@gmail.com, released under the MIT license
Something went wrong with that request. Please try again.