Skip to content

Instantly share code, notes, and snippets.

@jzellman
Created January 31, 2012 18:15
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 jzellman/1711976 to your computer and use it in GitHub Desktop.
Save jzellman/1711976 to your computer and use it in GitHub Desktop.
Var Args 9
class User < ActiveRecord::Base
# A user is only active if it has any subscriptions that are still active
def active?
subscriptions.active.any?
end
end
class AdminUser < User
# Admin users do not have subscriptions and are always active
def active?(*)
true
end
end
# Lookup User and see if they are active
User.find(1).active?
=> true
# Lookup Admin User and see if they are active
User.find(42).active?
=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment