Class: Admin::ShippingZonesController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/admin/shipping_zones_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



29
30
31
32
33
34
35
36
# File 'app/controllers/admin/shipping_zones_controller.rb', line 29

def create
  @shipping_zone = CountryShippingZone.new post_params[:shipping_zone]
  if @shipping_zone.save
    redirect_to admin_shipping_zones_path, notice: t(:successfully_created)
  else
    respond_with @shipping_zone
  end
end

#destroyObject



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/admin/shipping_zones_controller.rb', line 38

def destroy
  respond_to do |format|
    format.html do

      if @shipping_zone.destroy
        redirect_to admin_shipping_zones_path, notice: t(:successfully_deleted)
      else
        redirect_to admin_shipping_zones_path, error: t(:could_not_delete)
      end

    end
  end
end

#editObject



17
18
19
# File 'app/controllers/admin/shipping_zones_controller.rb', line 17

def edit
  respond_with @shipping_zone
end

#indexObject



7
8
9
10
# File 'app/controllers/admin/shipping_zones_controller.rb', line 7

def index
  @shipping_zones = CountryShippingZone.order('name asc')
  respond_with @shipping_zones
end

#newObject



12
13
14
15
# File 'app/controllers/admin/shipping_zones_controller.rb', line 12

def new
  @shipping_zone = ShippingZone.new
  respond_with @shipping_zone
end

#updateObject



21
22
23
24
25
26
27
# File 'app/controllers/admin/shipping_zones_controller.rb', line 21

def update
  if @shipping_zone.update_attributes post_params[:shipping_zone]
    redirect_to admin_shipping_zones_path, notice: t(:successfully_updated)
  else
    respond_with @shipping_zone
  end
end