Class: Dorsale::CustomerVault::IndividualsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/dorsale/customer_vault/individuals_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user_scope

Instance Method Details

#createObject



32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/dorsale/customer_vault/individuals_controller.rb', line 32

def create
  authorize! :create, ::Dorsale::CustomerVault::Individual

  @individual ||= current_user_scope.new_individual(individual_params)

  if @individual.save
    flash[:notice] = t("messages.individuals.create_ok")
    redirect_to @individual
  else
    render :new
  end
end

#destroyObject



56
57
58
59
60
61
62
63
64
65
66
# File 'app/controllers/dorsale/customer_vault/individuals_controller.rb', line 56

def destroy
  authorize! :delete, @individual

  if @individual.destroy
    flash[:notice] = t("messages.individuals.destroy_ok")
  else
    flash[:alert] = t("messages.individuals.destroy_error")
  end

  redirect_to dorsale.customer_vault_people_path
end

#editObject



24
25
26
27
28
29
30
# File 'app/controllers/dorsale/customer_vault/individuals_controller.rb', line 24

def edit
  authorize! :update, @individual

  @individual.build_address if @individual.address.nil?

  @tags ||= customer_vault_tag_list
end

#newObject



15
16
17
18
19
20
21
22
# File 'app/controllers/dorsale/customer_vault/individuals_controller.rb', line 15

def new
  authorize! :create, ::Dorsale::CustomerVault::Individual

  @individual ||= current_user_scope.new_individual
  @individual.build_address if @individual.address.nil?

  @tags ||= customer_vault_tag_list
end

#showObject



11
12
13
# File 'app/controllers/dorsale/customer_vault/individuals_controller.rb', line 11

def show
  authorize! :read, @individual
end

#updateObject



45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/dorsale/customer_vault/individuals_controller.rb', line 45

def update
  authorize! :update, @individual

  if @individual.update(individual_params)
    flash[:notice] = t("messages.individuals.update_ok")
    redirect_to @individual
  else
    render :edit
  end
end