Class: Trade::Admin::PromoteGoodsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @promote_good = PromoteGood.new(promote_good_params)

  unless @promote_good.save
    render :new, locals: { model: @promote_good }, status: :unprocessable_entity
  end
end

#destroyObject



45
46
47
# File 'app/controllers/trade/admin/promote_goods_controller.rb', line 45

def destroy
  @promote_good.destroy
end

#editObject



26
27
# File 'app/controllers/trade/admin/promote_goods_controller.rb', line 26

def edit
end

#goodsObject



13
14
15
16
17
# File 'app/controllers/trade/admin/promote_goods_controller.rb', line 13

def goods
  # todo support search
  @goods = params[:good_type].constantize.default_where(default_params).order(id: :desc)
  @promote_good = PromoteGood.new
end

#indexObject



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

def index
  q_params = {}.with_indifferent_access
  q_params.merge! params.permit(:promote_id, :good_type, :good_id)
  @promote_goods = PromoteGood.default_where(q_params).page(params[:page])
  if params[:promote_id]
    @promote = Promote.find params[:promote_id]
  end
end

#newObject



22
23
24
# File 'app/controllers/trade/admin/promote_goods_controller.rb', line 22

def new
  @promote_good = PromoteGood.new(params.permit(:promote_id, :good_type, :good_id))
end

#showObject



19
20
# File 'app/controllers/trade/admin/promote_goods_controller.rb', line 19

def show
end

#updateObject



37
38
39
40
41
42
43
# File 'app/controllers/trade/admin/promote_goods_controller.rb', line 37

def update
  @promote_good.assign_attributes(promote_good_params)

  unless @promote_good.save
    render :edit, locals: { model: @promote_good }, status: :unprocessable_entity
  end
end