Skip to content
acts as param
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
tasks
test
.gitignore
Gemfile
Gemfile.lock
MIT-LICENSE
README
Rakefile
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.