The controller ( users_controller.rb)def index @users = User.search(params[:search])end
def index @users = User.search(params[:search])end
and the method in user model:
def self.search(search) search.present? and all(:conditions => [ 'name LIKE ?', "%#{search.strip}%" ])end
No comments:
Post a Comment