class Photo < ActiveRecord::Base scope :filter, lambda { |filter| where('', :filter => "%#{filter}%") } attr_accessible :name class << self def list(page, filter) where('LOWER(name) LIKE :filter', :filter => "%#{filter}%").page(page) end end end