Submane
A rails engine for subscription management.
Installation
Add this line to your application's Gemfile:
gem "submane"And then execute:
$ bundleOr install it with bundle install:
$ bundle install submaneWe then run the following command to add migrations and config yml file
$ bin/rails generate submane:installFinally, we can add the class that subscriptions will be attached to.
Assuming "Account" class will hold the subscriptions, then we set is as the following string in config/submane.yml
account_class: AccountUsage
With the "Account" instance, let assume it is "account"
account = Account.new(...)Active plan
Get the active plan
account.active_planCheck if account has active plan
account.has_active_plan?Create Plans
Submane.create_plan(name: "", price: "", visual_order: 1)Subscription
Get all subscriptions
account.subscriptionsGet all active Subscriptions for a plan
Submane.plan_active_subscriptions({plan_id})Get active subscription
account.active_subscriptionContributing
Contribution directions go here.
License
The gem is available as open source under the terms of the MIT License.