Class: Admin::ShippingMethodsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/admin/shipping_methods_controller.rb', line 34

def create
  respond_to do |format|
    format.html do

      @shipping_method = @shipping_zone.shipping_methods.build(params[:shipping_method])
      if @shipping_method.save
        redirect_to admin_shipping_zones_path, notice: t(:successfully_created)
      else
        render action: :new
      end

    end
  end
end

#destroyObject



65
66
67
68
69
70
71
# File 'app/controllers/admin/shipping_methods_controller.rb', line 65

def destroy
  if @shipping_method.update_attributes(active: false)
    redirect_to admin_shipping_zones_path, notice: t(:successfully_deleted)
  else
    redirect_to admin_shipping_zones_path, error: t(:could_not_delete)
  end
end

#disableObject



13
14
15
16
# File 'app/controllers/admin/shipping_methods_controller.rb', line 13

def disable
  @shipping_method.disable!
  render json: { html:  render_shipping_method(@shipping_method) }
end

#editObject



30
31
32
# File 'app/controllers/admin/shipping_methods_controller.rb', line 30

def edit
  respond_with @shipping_method
end

#enableObject



18
19
20
21
22
23
# File 'app/controllers/admin/shipping_methods_controller.rb', line 18

def enable
  @shipping_method = ShippingMethod.where(shipping_zone_id: @shipping_zone.id, id: params[:id]).first

  @shipping_method.enable!
  render json: { html:  render_shipping_method(@shipping_method) }
end

#newObject



25
26
27
28
# File 'app/controllers/admin/shipping_methods_controller.rb', line 25

def new
  @shipping_method = @shipping_zone.shipping_methods.build
  respond_with @shipping_method
end

#updateObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/controllers/admin/shipping_methods_controller.rb', line 49

def update
  respond_to do |format|
    format.html do

      @shipping_method = @shipping_zone.shipping_methods.find(params[:id])

      if @shipping_method.update_attributes(params[:shipping_method])
        redirect_to [:edit, :admin, @shipping_zone, @shipping_method], notice: t(:successfully_updated)
      else
        render action: :new
      end

    end
  end
end

#update_offsetObject



8
9
10
11
# File 'app/controllers/admin/shipping_methods_controller.rb', line 8

def update_offset
  @shipping_method.update_offset(params[:offset])
  render json: { html:  render_shipping_method(@shipping_method) }
end