11class JobApplicationsController < ApplicationController
22 include ActionView ::RecordIdentifier
3- before_action :set_job_application , only : [ :update , :destroy ]
3+ before_action :set_job_application , only : [ :edit , : update, :destroy ]
44
55 def index
66 @job_applications = filter_and_sort_job_applications
@@ -30,17 +30,21 @@ def new
3030 end
3131
3232 def edit
33+ respond_to do |format |
34+ format . html
35+ format . turbo_stream { render turbo_stream : turbo_stream . replace ( dom_id ( @job_application ) , partial : "form" , locals : { job_application : @job_application , title : "Edit" } ) }
36+ end
3337 end
3438
3539 def create
3640 @job_application = JobApplication . new ( job_application_params )
3741
3842 respond_to do |format |
3943 if @job_application . save
40- format . html { redirect_to root_path , notice : "Job application was successfully created." }
44+ format . html { redirect_to root_path , success : "Job application was successfully created." }
4145 format . turbo_stream do
4246 render turbo_stream : turbo_stream . redirect_advanced ( root_path )
43- flash [ :notice ] = "Job application was successfully created."
47+ flash [ :success ] = "Job application was successfully created."
4448 end
4549 else
4650 format . html { render :new , status : :unprocessable_entity }
@@ -57,10 +61,10 @@ def create
5761 def update
5862 respond_to do |format |
5963 if @job_application . update ( job_application_params )
60- format . html { redirect_to root_path , notice : "Job application was successfully updated." }
64+ format . html { redirect_to root_path , success : "Job application was successfully updated." }
6165 format . turbo_stream do
6266 render turbo_stream : turbo_stream . redirect_advanced ( root_path )
63- flash [ :notice ] = "Job application was successfully updated."
67+ flash [ :success ] = "Job application was successfully updated."
6468 end
6569 else
6670 format . html { render :edit , status : :unprocessable_entity }
@@ -71,9 +75,9 @@ def update
7175 def destroy
7276 @job_application . destroy
7377 respond_to do |format |
74- format . html { redirect_to root_path , notice : "Job application was successfully deleted." }
78+ format . html { redirect_to root_path , success : "Job application was successfully deleted." }
7579 format . turbo_stream {
76- flash . now [ :notice ] = "Job application was successfully deleted."
80+ flash . now [ :success ] = "Job application was successfully deleted."
7781 render turbo_stream : [
7882 turbo_stream . remove ( @job_application ) ,
7983 turbo_stream . update ( "job_application_count" , JobApplication . count ) ,
0 commit comments