Sha256: c319ffbe74a28bf7fc7a3c7dbe0ac83aea91ffbc79df1b61f95599e24173cb5c

Contents?: true

Size: 933 Bytes

Versions: 5

Compression:

Stored size: 933 Bytes

Contents

class Iugu::PlanController < Iugu::AccountSettingsController
  before_filter(:only => [:index, :change]) { |c| c.must_be :owner, :id }

  def index
    params[:id] ? @account = current_user.accounts.find(params[:id]) : @account = current_user_account.account
    get_index_data
    render 'iugu/plan/index'
  end

  def change
    return unless params[:plan]
    params[:id] ? @account = current_user.accounts.find(params[:id]) : @account = current_user_account.account

    subscription = Iugu::Api::Subscription.find @account.subscription_id.to_uuid.to_s
    @account.clear_cached_subscription_features if subscription.change_plan params[:plan]

    get_index_data
    render 'iugu/plan/index'
  end

  private

  def get_index_data
    @currency = locale_to_currency I18n.locale
    @plans = Iugu::Api::Plan.with_currency @currency

    @subscription = Iugu::Api::Subscription.find @account.subscription_id.to_uuid.to_s
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
iugusdk-1.0.0.alpha.30 app/controllers/iugu/plan_controller.rb
iugusdk-1.0.0.alpha.29 app/controllers/iugu/plan_controller.rb
iugusdk-1.0.0.alpha.28 app/controllers/iugu/plan_controller.rb
iugusdk-1.0.0.alpha.27 app/controllers/iugu/plan_controller.rb
iugusdk-1.0.0.alpha.26 app/controllers/iugu/plan_controller.rb