Created
June 2, 2015 07:59
-
-
Save lorenzosinisi/c295dedb6dd1d5ee16cb to your computer and use it in GitHub Desktop.
Limitating resource that a user can create
This file contains 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
def jobs_count_within_user | |
limit = LIMIT | |
if self.user.jobs.count > limit | |
errors.add(:base, "Every user can create max #{limit} jobs") | |
false | |
else | |
true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment