Fix job redirects

This commit is contained in:
Trevor Vallender 2023-11-21 14:09:51 +00:00
parent 6b1646e180
commit 73d3066b74
3 changed files with 6 additions and 4 deletions

View File

@ -18,7 +18,7 @@ class JobsController < ApplicationController
def update
if @job.update(job_params)
redirect_to @job
redirect_to job_path(@job, project_id: @job.project.id)
else
render :edit
end
@ -26,13 +26,14 @@ class JobsController < ApplicationController
def create
if @job = Job.create(job_params)
redirect_to @job
redirect_to job_path(@job, project_id: @job.project.id)
else
render :edit
end
end
def destroy
@project = @job.project
if @job.destroy
redirect_to jobs_path(project_id: @project.id)
else

View File

@ -4,6 +4,8 @@ class Job < ActiveRecord::Base
:name,
presence: true
belongs_to :project
scope :project, ->(project) { where(project_id: project.id) }
def time_logged

View File

@ -21,8 +21,7 @@
</p>
<p>
<%= f.label :project_id %>
<%= f.number_field :project_id %>
<%= f.hidden_field :project_id, value: @project.id %>
</p>
<p>