Class: CandidaturesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- CandidaturesController
- Includes:
- Applicat::Mvc::Controller::Resource
- Defined in:
- app/controllers/candidatures_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #parent ⇒ Object
- #resource ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
46 47 |
# File 'app/controllers/candidatures_controller.rb', line 46 def edit end |
#index ⇒ Object
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 |
#new ⇒ Object
28 29 30 31 |
# File 'app/controllers/candidatures_controller.rb', line 28 def new @candidature = Candidature.new @candidature.vacancy = parent end |
#parent ⇒ Object
66 67 68 |
# File 'app/controllers/candidatures_controller.rb', line 66 def parent @vacancy end |
#resource ⇒ Object
62 63 64 |
# File 'app/controllers/candidatures_controller.rb', line 62 def resource @candidature end |
#show ⇒ Object
23 24 25 26 |
# File 'app/controllers/candidatures_controller.rb', line 23 def show @vacancy = @candidature.vacancy @comments = @candidature.comments end |
#update ⇒ Object
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 |