Candidate Keys

Alters find to include candidate keys of one’s own design. Useful when combined with to_param.

class Books < ActiveRecord::Base
  on_candidate_keys :find_by_isbn
  def to_param
    read_attribute :isbn
  end
end
Book.find("0977616630")

Tags

You need to Login to tag this item.