Skip to content

Instantly share code, notes, and snippets.

@leomao10
Created June 27, 2012 12:20
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 leomao10/3003714 to your computer and use it in GitHub Desktop.
Save leomao10/3003714 to your computer and use it in GitHub Desktop.
Class Methods vs Scope
class User < ActiveRecord::Base
scope :with_first_name, lambda { |first_name| where(:first_name => first_name) }
def self.with_last_name(last_name)
where(:last_name => last_name)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment