Guest User

Untitled

a guest
May 18th, 2018
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. class Vendor < ActiveRecord::Base
  2. named_scope :alphabetical, lambda { |letter| { :conditions => ['lower(name) LIKE ?', "#{letter.downcase}%"] } }
  3. end
  4.  
  5.  
  6. $ script/console
  7.  
  8. >> Vendor.alphabetical "c"
  9. => [#<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">]
  10. >> Vendor.alphabetical "C"
  11. => [#<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