0

User has package. User belongs to package and package has many users.One to many relation between user and package. Gold, silver,bronze are packages. So how can we authorize the user of silver package can add 100 posts per month , gold package user can add 200 posts per month and bronze package user can add 50 posts per month.

User101
  • 55
  • 1
  • 10

1 Answers1

0

You could do something like this in the PostPolicy

def create? user.montly_posts >= user.allowed_posts end

And in the User model add the helper methods for monthly_posts and allowed_posts

Scott
  • 2,248
  • 3
  • 22
  • 24