Skip to content

Instantly share code, notes, and snippets.

@stevenbristol
Created August 9, 2012 17:32
Show Gist options
  • Save stevenbristol/3306232 to your computer and use it in GitHub Desktop.
Save stevenbristol/3306232 to your computer and use it in GitHub Desktop.
scope with proc usage
class User < ActiveRecord::Base
scope :hello, Proc.new { |param| param.blank? ? where("") : where("param = ?", param) }
end
User.hello(current_user_or_other_security_thig_or_somethng)
User.hello( "" )
User.hello
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment