I’m trying to implement plans into an SaaS application. Each plan would determine the price of a package and limitations such as number of users allowed, number of emails one is allowed to send, access to different kind of reports etc. I currently have Plan model with couple of subclasses (free, basic & premium) which handle price and description.
I’m guessing I have to build a policy object of some kind (maybe policy isn’t even a proper naming) and do all the checking through that model. So in
UsersController I’d have filters like
before_action :ensure_creations_allowed to check if
Survey.plan.users_limit >= users.count. In
ReportsController I’d have checks for each type of the report. Sounds a lot like I’d need something similar to CanCan’s
can? checks which I could use in controller and views.
Am I heading into the right direction? I feel like all my controllers would have a lot of before filters each checking a particular limitation? What are your recommendations for solving this kind of problem? I would appreciate any suggestion or tip for tackling this.