Class: Saasaparilla::PlansController

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

Instance Method Summary collapse

Methods included from Authentication::InstanceMethods

included, #require_current_billable

Instance Method Details

#editObject



6
7
8
# File 'app/controllers/saasaparilla/plans_controller.rb', line 6

def edit
  @plans = Plan.all(:order => 'price ASC')
end

#updateObject



10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/saasaparilla/plans_controller.rb', line 10

def update
  if params[:subscription][:plan_id] == ""
    @subscription.cancel
    redirect_to(subscription_path, :notice => 'You have been downgraded to the free plan.')
    return
  elsif @subscription.downgrade_plan_to(params[:subscription][:plan_id])
    redirect_to(subscription_path, :notice => 'Plan was successfully changed.')
  else
    render :action => "edit"
  end
end