Class: AppealsController

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

Instance Method Summary collapse

Instance Method Details

#createObject

post /appeals



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/appeals_controller.rb', line 15

def create
  @entity = Appeal.new(creation_parameters)
  if @entity.save
    next_page = feedback_path
    respond_to do |format|
      format.html { redirect_to(next_page, notice: t('appeals.create.success')) }
      format.json { render(json: { links: { next: next_page } }) }
      format.js { render js: "document.location.href = '#{next_page}'" }
    end
  else
    render :new, status: :bad_request
  end
end

#destroyObject

delete /appeals/:id



45
46
47
48
49
50
# File 'app/controllers/appeals_controller.rb', line 45

def destroy
  if @entity.update(deleted: true)
    flash[:notice] = t('appeals.destroy.success')
  end
  redirect_to admin_appeals_path
end

#newObject

get /appeals/new



9
10
11
12
# File 'app/controllers/appeals_controller.rb', line 9

def new
  @entity = Appeal.new
  @entity.apply_user(current_user)
end

#updateObject

patch /appeals/:id



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/appeals_controller.rb', line 30

def update
  if @entity.update(entity_parameters)
    next_page = admin_appeal_path(id: @entity.id)
    respond_to do |format|
      format.html { redirect_to(next_page) }
      format.json { render(json: { links: { next: next_page } }) }
      format.js { render js: "document.location.href = '#{next_page}'" }
    end
    AppealsMailer.appeal_reply(@entity.id).deliver_later
  else
    render :edit, status: :bad_request
  end
end