There are plenty of reasons you want to attach a subscription to another model than the User model. Sjabloon is set up to make this easy, but involves a bit more manual work. It should ideally be done early stage.
- Rollback the migration (rails db:rollback) that adds the payment fields to the users table (add_payment_fields_to_users) or to
_people(if you choose this). Find/replace
:userswith whatever model you want to add it to (make sure the table name is plural!). Re-run the migration.
payer_classto your new model name (eg. “Team”).
model/user.rbto your new model.
- Lastly, in
app/controllers/application_controller.rb, change the
current_payerto include the “current model” for which you want to add subscriptions to (eg “current_team”). For User this is the default
current_userthat comes with Devise. You need to create a “current model” (eg.
current__team) method yourself.
A Rails SaaS starter kit to build successful products
35+ developers, companies and freelancers bought Sjabloon in the last 4 weeks