Sha256: f1f1cddec288a6b3dfcdb5142980a000bca2f7a363a93938014175b48f1cf61b
Contents?: true
Size: 1.44 KB
Versions: 27
Compression:
Stored size: 1.44 KB
Contents
class PlansController < ApplicationController layout Saucy::Layouts.to_proc def index @plans = Plan.ordered notify_observers_of_plan_list_view end def edit @plans = Plan.ordered @account = current_account end def update @plans = Plan.ordered @account = current_account from_plan = @account.plan if @account.save_customer_and_subscription!(params[:account]) to_plan = @account.plan notify_observers_of_plan_change(from_plan, to_plan) redirect_to edit_account_path(@account), :notice => t('.update.notice', :default => "Plan changed successfully") else render :edit end end private def notify_observers_of_plan_change(from_plan, to_plan) notify_observers("plan_upgraded", from_plan, to_plan) if from_plan.price < to_plan.price notify_observers("plan_downgraded", from_plan, to_plan) if from_plan.price > to_plan.price end def notify_observers_of_plan_list_view Saucy::Notifications.notify_observers("plan_list_viewed", :request => request) end def notify_observers(event_name, from_plan, to_plan) Saucy::Notifications.notify_observers(event_name, :account => @account, :request => request, :from_plan => from_plan, :to_plan => to_plan) end end
Version data entries
27 entries across 27 versions & 1 rubygems