Class: VacanciesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/vacancies_controller.rb', line 26

def create
  @vacancy = Vacancy.new(params[:vacancy])
  @vacancy.resource_type = 'User'
  
  if @vacancy.project.user_id == current_user.id
    @vacancy.do_open
  else
    @vacancy.author_id = current_user.id 
    @vacancy.recommend
  end
  
  if @vacancy.save
    redirect_to @vacancy, notice: t('general.form.successfully_created')
  else
    render :new
  end
end

#destroyObject



58
59
60
61
62
# File 'app/controllers/vacancies_controller.rb', line 58

def destroy
  @vacancy = Vacancy.find(params[:id])
  @vacancy.destroy
  redirect_to vacancies_url, notice: t('general.form.destroyed')
end

#editObject



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

def edit
  @vacancy = Vacancy.find(params[:id])
end

#indexObject



12
13
14
# File 'app/controllers/vacancies_controller.rb', line 12

def index
  @vacancies = @project ? @project.vacancies : Vacancy.where(type: nil).all
end

#newObject



20
21
22
23
24
# File 'app/controllers/vacancies_controller.rb', line 20

def new
  @vacancy = Vacancy.new
  
  @vacancy.project = @project if @project
end

#resourceObject



64
65
66
# File 'app/controllers/vacancies_controller.rb', line 64

def resource
  @vacancy
end

#showObject



16
17
18
# File 'app/controllers/vacancies_controller.rb', line 16

def show
  @comments = @vacancy.comments
end

#updateObject



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

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