Class: CheckoutTypesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/checkout_types_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /checkout_types POST /checkout_types.json



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/controllers/checkout_types_controller.rb', line 54

def create
  if @user_group
    @checkout_type = @user_group.checkout_types.new(checkout_type_params)
  else
    @checkout_type = CheckoutType.new(checkout_type_params)
  end

  respond_to do |format|
    if @checkout_type.save
      format.html { redirect_to @checkout_type, notice: t('controller.successfully_created', model: t('activerecord.models.checkout_type')) }
      format.json { render json: @checkout_type, status: :created, location: @checkout_type }
    else
      format.html { render action: "new" }
      format.json { render json: @checkout_type.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /checkout_types/1 DELETE /checkout_types/1.json



93
94
95
96
97
98
99
100
101
102
103
# File 'app/controllers/checkout_types_controller.rb', line 93

def destroy
  if @user_group
    @checkout_type = @user_group.checkout_types.find(params[:id])
  end
  @checkout_type.destroy

  respond_to do |format|
    format.html { redirect_to checkout_types_url }
    format.json { head :no_content }
  end
end

#editObject

GET /checkout_types/1/edit



49
50
# File 'app/controllers/checkout_types_controller.rb', line 49

def edit
end

#indexObject

GET /checkout_types GET /checkout_types.json



7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/checkout_types_controller.rb', line 7

def index
  if @user_group
    @checkout_types = @user_group.checkout_types.order('checkout_types.position')
  else
    @checkout_types = CheckoutType.order(:position)
  end

  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @checkout_types }
  end
end

#newObject

GET /checkout_types/new GET /checkout_types/new.json



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

def new
  if @user_group
    @checkout_type = @user_group.checkout_types.new
  else
    @checkout_type = CheckoutType.new
  end

  respond_to do |format|
    format.html # new.html.erb
    format.json { render json: @checkout_type }
  end
end

#showObject

GET /checkout_types/1 GET /checkout_types/1.json



22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/checkout_types_controller.rb', line 22

def show
  if @user_group
    @checkout_type = @user_group.checkout_types.find(params[:id])
  end

  respond_to do |format|
    format.html # show.html.erb
    format.json { render json: @checkout_type }
  end
end

#updateObject

PUT /checkout_types/1 PUT /checkout_types/1.json



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'app/controllers/checkout_types_controller.rb', line 74

def update
  if params[:move]
    move_position(@checkout_type, params[:move])
    return
  end

  respond_to do |format|
    if @checkout_type.update_attributes(checkout_type_params)
      format.html { redirect_to @checkout_type, notice: t('controller.successfully_updated', model: t('activerecord.models.checkout_type')) }
      format.json { head :no_content }
    else
      format.html { render action: "edit" }
      format.json { render json: @checkout_type.errors, status: :unprocessable_entity }
    end
  end
end