Created
January 31, 2012 18:17
-
-
Save jzellman/1711988 to your computer and use it in GitHub Desktop.
Var Args 10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
# A user is active during a period if it has any subscriptions | |
# that are active during that period | |
def active?(start_date, end_date) | |
subscriptions.active_in_period(start_date, end_date).any? | |
end | |
end | |
# Lookup User and see if they are active | |
User.find(1).active?(start_date, end_date) | |
=> false | |
# Lookup AdminUser and see if they are active | |
User.find(42).active?(start_date, end_date) | |
=> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment