Class: PointsProgram::SignUpBasedController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/points_program/sign_up_based_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/admin/points_program/sign_up_based_controller.rb', line 17

def create
  @points_program = SpecialBonus.new params.require(:special_bonus).permit!
  @points_program.campaign_type = 3
  if @points_program.save
    redirect_to 
  else
    flash.now[:alert] = @points_program.errors.full_messages.to_sentence
    render 'edit'
  end
end

#destroyObject



39
40
41
42
43
44
45
# File 'app/controllers/admin/points_program/sign_up_based_controller.rb', line 39

def destroy
  if @points_program.delete
    redirect_to , notice: 'Delete success'
  else
    redirect_to , alert: 'Delete failed'
  end
end

#editObject



28
# File 'app/controllers/admin/points_program/sign_up_based_controller.rb', line 28

def edit; end

#indexObject



7
8
9
10
11
# File 'app/controllers/admin/points_program/sign_up_based_controller.rb', line 7

def index
  @points_programs = SpecialBonus.where(SpecialBonus.arel_table[:sign_up_code].not_eq(nil))
  etag = CityHash.hash32([self.class.to_s, @points_programs.cache_key])
  return unless stale?(etag: etag)
end

#newObject



13
14
15
# File 'app/controllers/admin/points_program/sign_up_based_controller.rb', line 13

def new
  @points_program = SpecialBonus.new # campaign_type: 3
end

#updateObject



30
31
32
33
34
35
36
37
# File 'app/controllers/admin/points_program/sign_up_based_controller.rb', line 30

def update
  if @points_program.update_attributes params.require(:special_bonus).permit!
    redirect_to , notice: 'Data updated'
  else
    flash.now.alert = @points_program.errors.full_messages.to_sentence
    render 'edit'
  end
end