Class: VacanciesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- VacanciesController
- Includes:
- Applicat::Mvc::Controller::Resource
- Defined in:
- app/controllers/vacancies_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #resource ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
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. = current_user.id @vacancy.recommend end if @vacancy.save redirect_to @vacancy, notice: t('general.form.successfully_created') else render :new end end |
#destroy ⇒ Object
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 |
#edit ⇒ Object
44 45 46 |
# File 'app/controllers/vacancies_controller.rb', line 44 def edit @vacancy = Vacancy.find(params[:id]) end |
#index ⇒ Object
12 13 14 |
# File 'app/controllers/vacancies_controller.rb', line 12 def index @vacancies = @project ? @project.vacancies : Vacancy.where(type: nil).all end |
#new ⇒ Object
20 21 22 23 24 |
# File 'app/controllers/vacancies_controller.rb', line 20 def new @vacancy = Vacancy.new @vacancy.project = @project if @project end |
#resource ⇒ Object
64 65 66 |
# File 'app/controllers/vacancies_controller.rb', line 64 def resource @vacancy end |
#show ⇒ Object
16 17 18 |
# File 'app/controllers/vacancies_controller.rb', line 16 def show @comments = @vacancy.comments end |
#update ⇒ Object
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 |