Class: Trade::Admin::PromoteChargesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/trade/admin/promote_charges_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @promote_charge = @promote.promote_charges.build(promote_charge_params)
  
  if @promote_charge.save
    render :new, locals: { model: @promote_charge }, status: :unprocessable_entity
  end
end

#destroyObject



41
42
43
# File 'app/controllers/trade/admin/promote_charges_controller.rb', line 41

def destroy
  @promote_charge.destroy
end

#editObject



29
30
31
# File 'app/controllers/trade/admin/promote_charges_controller.rb', line 29

def edit

end

#indexObject



5
6
7
8
9
10
11
# File 'app/controllers/trade/admin/promote_charges_controller.rb', line 5

def index
  q_params = {}
  q_params.merge! params.permit(PromoteCharge.extra_columns)
  q_params.merge! 'filter_min-lte': params[:value], 'filter_max-gte': params[:value]
  
  @promote_charges = @promote.promote_charges.default_where(q_params).order(min: :asc).page(params[:page]).per(params[:per])
end

#newObject



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

def new
  @promote_charge = @promote.promote_charges.build
end

#optionsObject



13
14
15
# File 'app/controllers/trade/admin/promote_charges_controller.rb', line 13

def options

end

#updateObject



33
34
35
36
37
38
39
# File 'app/controllers/trade/admin/promote_charges_controller.rb', line 33

def update
  @promote_charge.assign_attributes(promote_charge_params)

  if @promote_charge.save
    render :edit, locals: { model: @promote_charge }, status: :unprocessable_entity
  end
end