summaryrefslogtreecommitdiff
path: root/billing/app/controllers/subscriptions_controller.rb
diff options
context:
space:
mode:
authorjessib <jessib@leap.se>2013-05-06 12:58:34 -0700
committerAzul <azul@leap.se>2013-07-17 10:47:13 +0200
commit62b32320f38627dad870c7b3157576c48674c42b (patch)
tree3f64557604995d84a1477b7e66f820baffd3ed59 /billing/app/controllers/subscriptions_controller.rb
parentfe0ac266a797523492fe3b2c750e7862f51b152f (diff)
Show single active subscription from user's page, with link to index showing all the user's subscriptions.
Diffstat (limited to 'billing/app/controllers/subscriptions_controller.rb')
-rw-r--r--billing/app/controllers/subscriptions_controller.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/billing/app/controllers/subscriptions_controller.rb b/billing/app/controllers/subscriptions_controller.rb
index b248be5..9217979 100644
--- a/billing/app/controllers/subscriptions_controller.rb
+++ b/billing/app/controllers/subscriptions_controller.rb
@@ -6,7 +6,7 @@ class SubscriptionsController < ApplicationController
# don't show link to subscribe if they are already subscribed?
customer = Customer.find_by_user_id(current_user.id)
- if subscription = customer.single_subscription
+ if subscription = customer.subscriptions # will return active subscription, if it exists
redirect_to subscription_path(subscription.id), :notice => 'You already have an active subscription'
else
credit_card = customer.default_credit_card #safe to assume default?
@@ -25,6 +25,11 @@ class SubscriptionsController < ApplicationController
@result = Braintree::Subscription.cancel params[:id]
end
+ def index
+ customer = Customer.find_by_user_id(current_user.id)
+ @subscriptions = customer.subscriptions(nil, false)
+ end
+
private
def fetch_subscription