Class: Saasaparilla::SubscriptionController

Inherits:
ApplicationController show all
Includes:
Authentication::InstanceMethods
Defined in:
app/controllers/saasaparilla/subscription_controller.rb

Instance Method Summary collapse

Methods included from Authentication::InstanceMethods

included, #require_current_billable

Instance Method Details

#createObject



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

#destroyObject



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

#newObject

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

#reactivateObject



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

#showObject



32
33
34
# File 'app/controllers/saasaparilla/subscription_controller.rb', line 32

def show

end