Class: Shoppe::AddressesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/shoppe/addresses_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/shoppe/addresses_controller.rb', line 15

def create
  @address = @customer.addresses.build(safe_params)
  if @customer.addresses.count == 0
    @address.default = true
  end
  if @customer.save
    redirect_to @customer, :flash => {:notice => "Address has been created successfully"}
  else
    render action: "new"
  end
end

#destroyObject


35
36
37
38
# File 'app/controllers/shoppe/addresses_controller.rb', line 35

def destroy
  @address.destroy
  redirect_to @customer, :flash => {:notice => "Address has been deleted successfully"}
end

#editObject


12
13
# File 'app/controllers/shoppe/addresses_controller.rb', line 12

def edit
end

#newObject


8
9
10
# File 'app/controllers/shoppe/addresses_controller.rb', line 8

def new
  @address = Shoppe::Address.new
end

#updateObject


27
28
29
30
31
32
33
# File 'app/controllers/shoppe/addresses_controller.rb', line 27

def update
  if @address.update(safe_params)
    redirect_to @customer, :flash => {:notice => "Address has been updated successfully"}
  else
    render action: "edit"
  end
end