Created
November 3, 2011 09:37
-
-
Save kibyegn/1336140 to your computer and use it in GitHub Desktop.
Billing Plans
This file contains hidden or 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
I'm building a billing plan into my rails app. I have 3 different plans (free, pro, enterprise) and want to be able to assign users to a plan and enable them to switch between plans. I'm trying to figure out what would be the best way of doing this. | |
1. Create a BillingPlan model with the 3 plans and the fields such as whether a feature is available in that plan or not. example {:free => {:analytics => false, :pdf_reports => false, :users => 1}, :pro => {:analytics => true, :pdf_reports => true, :users => 3}} So if say I want to see if the current user is able to download pdf reports, i just pull his plan_id and check if pdf_reports field is true or false. If I want to edit the plans I would update the plans in the database. | |
2. Another way I thought possible is to have a billing_plan field which holds the users plan. Then the plan variables store them on a YAML file and then load the yaml file in the config folder and load it up inside an initializer thereby making the data in the YAML file available as a hash of constants. This would enable me to just pull the info by writing BILLING_PLANS[current_user.billing_plan]. Editing plans I would just go ahead and edit the YAML file and change the values. | |
What are your thoughts on this. Which is the best solution for this? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment