Class: Saasaparilla::SubscriptionController
Instance Method Summary
collapse
included, #require_current_billable
Instance Method Details
#create ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/saasaparilla/subscription_controller.rb', line 15
def create
@subscription = current_billable.build_subscription(params[:subscription])
begin
if @subscription.save
redirect_to subscription_path
flash[:notice] = "Your subscription was successfully created."
else
render :action => "new"
flash[:error] = "Your subscription could not be created due to errors. Please review the form and correct them."
end
rescue Exception => e
flash[:error] = e.message
render :action => "new"
flash.discard
end
end
|
#destroy ⇒ Object
46
47
48
49
50
51
52
|
# File 'app/controllers/saasaparilla/subscription_controller.rb', line 46
def destroy
if @subscription.cancel
flash[:notice] = "Your subscription has been canceled."
redirect_to subscription_path
end
end
|
#new ⇒ Object
overide with authorization
9
10
11
12
13
|
# File 'app/controllers/saasaparilla/subscription_controller.rb', line 9
def new
@subscription = current_billable.build_subscription
@subscription.build_contact_info
@subscription.build_credit_card
end
|
#reactivate ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'app/controllers/saasaparilla/subscription_controller.rb', line 36
def reactivate
if @subscription.reactivate!
redirect_to subscription_path
flash[:notice] = "Your subscription was successfully reactivated."
else
redirect_to subscription_path
flash[:error] = "There was a problem reactivating your account."
end
end
|
#show ⇒ Object
32
33
34
|
# File 'app/controllers/saasaparilla/subscription_controller.rb', line 32
def show
end
|