Class: Spike::ApplicantsController

Inherits:
Applicants::ApplicationController
  • Object
show all
Defined in:
app/controllers/applicants/spike/applicants_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



47
48
49
50
# File 'app/controllers/applicants/spike/applicants_controller.rb', line 47

def destroy
  @applicant.disable!
  head :ok
end

#eventObject



39
40
41
42
43
44
45
# File 'app/controllers/applicants/spike/applicants_controller.rb', line 39

def event
  @applicant.update_attributes({ event: params[:event] }) if params[:event]
  respond_to do |format|
    format.html { redirect_to spike_root_path, notice: "Applicant updated!" }
    format.json { head :ok }
  end
end

#indexObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/applicants/spike/applicants_controller.rb', line 10

def index
  if params[:q]
    @applicants = Applicants::Applicant.where(params[:q].delete_if {|k, v| v.blank?})
  else
    offset = params[:offset] || 0
    limit  = params[:limit]  || 100
    state  = params[:state]  || 'reviewable'
    applicants_of_state = Applicants::Applicant.with_state(state)

    @applicants  = if state == 'reviewable'
                     applicants_of_state.offset(offset).limit(limit).order('updated_at ASC')
                    else
                     applicants_of_state.offset(offset).limit(limit).order('updated_at DESC')
                    end
    @total       = applicants_of_state.count
    @stale_count = applicants_of_state.stale.count
  end
end

#showObject



29
30
# File 'app/controllers/applicants/spike/applicants_controller.rb', line 29

def show
end

#updateObject



32
33
34
35
36
37
# File 'app/controllers/applicants/spike/applicants_controller.rb', line 32

def update
  @applicant.update_attributes params[:applicant]
  respond_to do |format|
    format.html { redirect_to spike_root_path, notice: "Applicant updated!" }
  end
end