Class: CandidaturesController

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

Instance Method Summary collapse

Methods included from Applicat::Mvc::Controller::Resource

included

Methods inherited from ApplicationController

#current_ability

Methods included from Voluntary::V1::BaseController

#voluntary_application_javascripts, #voluntary_application_repository_path, #voluntary_application_stylesheets

Methods included from Applicat::Mvc::Controller

included

Instance Method Details

#createObject



33
34
35
36
37
38
39
40
41
42
43
# 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
  
  if @candidature.save
    redirect_to @candidature, notice: t('general.form.successfully_created')
  else
    render :new
  end
end

#destroyObject



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

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

#editObject



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

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



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

def parent
  @vacancy
end

#resourceObject



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

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



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

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