From 2829e7020abcf6d2f708fbc7dfb3db98ad174255 Mon Sep 17 00:00:00 2001 From: jessib Date: Mon, 15 Apr 2013 12:13:33 -0700 Subject: Displaying of user's subscription. Still not committed to whether user can have multiple subscriptions at a time or not. --- billing/app/controllers/subscriptions_controller.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'billing/app/controllers/subscriptions_controller.rb') diff --git a/billing/app/controllers/subscriptions_controller.rb b/billing/app/controllers/subscriptions_controller.rb index 38b17b4..af20faf 100644 --- a/billing/app/controllers/subscriptions_controller.rb +++ b/billing/app/controllers/subscriptions_controller.rb @@ -5,9 +5,17 @@ class SubscriptionsController < ApplicationController # don't show link to subscribe if they are already subscribed? customer = Customer.find_by_user_id(current_user.id) - @payment_method_token = customer.default_credit_card.token - @plans = Braintree::Plan.all + if subscription = customer.single_subscription + redirect_to subscription_path(subscription.id) + else + credit_card = customer.default_credit_card #safe to assume default? + @payment_method_token = credit_card.token + @plans = Braintree::Plan.all + end + end + def show + @subscription = Braintree::Subscription.find params[:id] end -- cgit v1.2.3