Sha256: f04d9a296e8acd2dd9b5829f63114cafbfd6cf9ab7df8983db7122b83c5b74b6

Contents?: true

Size: 1.37 KB

Versions: 19

Compression:

Stored size: 1.37 KB

Contents

module Effective
  class CustomersController < ApplicationController
    layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:customers] : EffectiveOrders.layout)

    before_action :authenticate_user!

    # Get here by visiting /customer/settings
    def edit
      @customer = Effective::Customer.where(user: current_user).first!
      EffectiveOrders.authorize!(self, :edit, @customer)

      @subscripter = Effective::Subscripter.new(customer: @customer, user: @customer.user)

      @page_title ||= "Customer #{current_user.to_s}"
    end

    def update
      @customer = Effective::Customer.where(user: current_user).first!
      EffectiveOrders.authorize!(self, :update, @customer)

      @subscripter = Effective::Subscripter.new(customer: @customer, user: @customer.user)
      @subscripter.assign_attributes(subscripter_params)

      @page_title ||= "Customer #{current_user.to_s}"

      if (@subscripter.save! rescue false)
        flash[:success] = "Successfully updated customer settings"
        redirect_to(effective_orders.customer_settings_path)
      else
        flash.now[:danger] = "Unable to update customer settings: #{@subscripter.errors.full_messages.to_sentence}"
        render :edit
      end
    end

    private

    # StrongParameters
    def subscripter_params
      params.require(:effective_subscripter).permit(:stripe_token)
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
effective_orders-3.2.3 app/controllers/effective/customers_controller.rb
effective_orders-3.2.2 app/controllers/effective/customers_controller.rb
effective_orders-3.2.1 app/controllers/effective/customers_controller.rb
effective_orders-3.2.0 app/controllers/effective/customers_controller.rb
effective_orders-3.1.7 app/controllers/effective/customers_controller.rb
effective_orders-3.1.6 app/controllers/effective/customers_controller.rb
effective_orders-3.1.4 app/controllers/effective/customers_controller.rb
effective_orders-3.1.3 app/controllers/effective/customers_controller.rb
effective_orders-3.1.0 app/controllers/effective/customers_controller.rb
effective_orders-3.0.4 app/controllers/effective/customers_controller.rb
effective_orders-3.0.3 app/controllers/effective/customers_controller.rb
effective_orders-3.0.2 app/controllers/effective/customers_controller.rb
effective_orders-4.0.0beta5 app/controllers/effective/customers_controller.rb
effective_orders-4.0.0beta4 app/controllers/effective/customers_controller.rb
effective_orders-4.0.0beta3 app/controllers/effective/customers_controller.rb
effective_orders-4.0.0beta2 app/controllers/effective/customers_controller.rb
effective_orders-4.0.0beta1 app/controllers/effective/customers_controller.rb
effective_orders-3.0.1 app/controllers/effective/customers_controller.rb
effective_orders-3.0.0 app/controllers/effective/customers_controller.rb