Skip to content

Instantly share code, notes, and snippets.

@mikespokefire
Forked from anonymous/controller
Created January 26, 2012 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikespokefire/1682664 to your computer and use it in GitHub Desktop.
Save mikespokefire/1682664 to your computer and use it in GitHub Desktop.
search
class LoginController < ApplicationController
def overview
@student = Student.search params[:search]
end
Model
class Student < ActiveRecord::Base
def self.search(query = nil)
if query && !query.blank?
self.find(:all, :conditions => ['student_name LIKE ?', "%#{query}%"])
else
[]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment