In this episode, we focus on how to check if a user is currently subscribed and whether they've cancelled their subscription. We start by exploring the simple subscribed
method available on the user model, which conveniently tells you if someone has an active subscription—just a true or false! If you're only dealing with a default subscription type, this is as easy as it gets, but you can also specify which subscription type to check if your app supports multiple plans.
We dive into the controller, play around with dumping out the subscription status, and see firsthand how it all works. If someone has cancelled their subscription, the subscribed
method will reflect that. To dig even deeper and check specifically if a subscription was cancelled (rather than just inactive), we use the subscription object directly—accessing it through the user, and then calling helper methods like cancelled
.
We also have a quick look at the source code to understand where these methods live, which is great if you're ever curious about customizing things. By the end, you’ll understand the difference between simply being "not subscribed" and having an explicitly cancelled subscription.
Next up, we’ll start building out more cool features—like protecting certain areas for subscribers, updating the navigation based on subscription status, and letting users manage their subscriptions from the dashboard. Stay tuned!