I'm looking to crea开发者_StackOverflow社区te an app that has a tiered account plan. I'd have free accounts and premium accounts.
What I'm looking for is a nice plug-in to help handle this throttling/authorization for me. I'm looking at CanCan as it seems to be the defacto, and Mr. Bates is awesome, but I had a question.
With CanCan, are you able to say, limit the times a user can complete the create action? I'd like to make it so a Free account can only create a certain number of projects or other model objects, is this possible CanCan?
Anyway, I'd just like some help getting started with Authorization plug-ins, preferable onces that have built in methods for throttling activity.
You could probably get this with CanCan using blocks to define the abilities. Something like
can :create, Project do |p|
user.plan.limit < user.projects
end
I would create a model method for this anyway. user.has_reached_limit?
or user.on_plan_limit?
Hope that helps,
NHI
Limiting the number of times a user create records of a model is a problem you can normally handle with custom model validation or by using action filters for you controller methods. I'm not aware of any gems or plugins that facilitate that sort of constraint, but I'd be interested if one does exist.
精彩评论