Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Vendor < ActiveRecord::Base
- named_scope :alphabetical, lambda { |letter| { :conditions => ['lower(name) LIKE ?', "#{letter.downcase}%"] } }
- end
- $ script/console
- >> Vendor.alphabetical "c"
- => [#<Vendor id: 287989278, name: "CORBIS", vendor_type_id: 706135966, address_id: 975874706, toll_free: "", website: "", username: "", password: "", credit: "", deleted_at: nil, created_at: "2008-06-20 09:39:38", updated_at: "2008-06-20 09:40:43">]
- >> Vendor.alphabetical "C"
- => [#<Vendor id: 287989278, name: "CORBIS", vendor_type_id: 706135966, address_id: 975874706, toll_free: "", website: "", username: "", password: "", credit: "", deleted_at: nil, created_at: "2008-06-20 09:39:38", updated_at: "2008-06-20 09:40:43">]
Add Comment
Please, Sign In to add comment