Class: CandidaturesController

Inherits:
ApplicationController
  • Object
show all
Includes:
Applicat::Mvc::Controller::Resource
Defined in:
app/controllers/candidatures_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/candidatures_controller.rb', line 33

def create
  @candidature = Candidature.new(params[:candidature])
  @candidature.resource_type = 'User'
  @candidature.resource_id = current_user.id
  @candidature.user_id = current_user.id
  
  if @candidature.save
    redirect_to @candidature, notice: t('general.form.successfully_created')
  else
    render :new
  end
end

#destroyObject



57
58
59
60
# File 'app/controllers/candidatures_controller.rb', line 57

def destroy
  @candidature.destroy
  redirect_to candidatures_url, notice: t('general.form.destroyed')
end

#editObject



46
47
# File 'app/controllers/candidatures_controller.rb', line 46

def edit
end

#indexObject



15
16
17
18
19
20
21
# File 'app/controllers/candidatures_controller.rb', line 15

def index
  @candidatures = if @vacancy
    @vacancy.candidatures.includes(:vacancy, :resource)
  else 
    Candidature.includes(:vacancy, :resource).where(resource_type: 'User')
  end
end

#newObject



28
29
30
31
# File 'app/controllers/candidatures_controller.rb', line 28

def new
  @candidature = Candidature.new
  @candidature.vacancy = parent
end

#parentObject



66
67
68
# File 'app/controllers/candidatures_controller.rb', line 66

def parent
  @vacancy
end

#resourceObject



62
63
64
# File 'app/controllers/candidatures_controller.rb', line 62

def resource
  @candidature
end

#showObject



23
24
25
26
# File 'app/controllers/candidatures_controller.rb', line 23

def show
  @vacancy = @candidature.vacancy
  @comments = @candidature.comments
end

#updateObject



49
50
51
52
53
54
55
# File 'app/controllers/candidatures_controller.rb', line 49

def update
  if @candidature.update_attributes(params[:candidature])
    redirect_to @candidature, notice: t('general.form.successfully_updated')
  else
    render :edit
  end
end