Skip to content

Instantly share code, notes, and snippets.

@lorenzosinisi
Created June 2, 2015 07:59
Show Gist options
  • Save lorenzosinisi/c295dedb6dd1d5ee16cb to your computer and use it in GitHub Desktop.
Save lorenzosinisi/c295dedb6dd1d5ee16cb to your computer and use it in GitHub Desktop.
Limitating resource that a user can create
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