Fix job redirects
This commit is contained in:
parent
6b1646e180
commit
73d3066b74
|
@ -18,7 +18,7 @@ class JobsController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if @job.update(job_params)
|
if @job.update(job_params)
|
||||||
redirect_to @job
|
redirect_to job_path(@job, project_id: @job.project.id)
|
||||||
else
|
else
|
||||||
render :edit
|
render :edit
|
||||||
end
|
end
|
||||||
|
@ -26,13 +26,14 @@ class JobsController < ApplicationController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
if @job = Job.create(job_params)
|
if @job = Job.create(job_params)
|
||||||
redirect_to @job
|
redirect_to job_path(@job, project_id: @job.project.id)
|
||||||
else
|
else
|
||||||
render :edit
|
render :edit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
@project = @job.project
|
||||||
if @job.destroy
|
if @job.destroy
|
||||||
redirect_to jobs_path(project_id: @project.id)
|
redirect_to jobs_path(project_id: @project.id)
|
||||||
else
|
else
|
||||||
|
|
|
@ -4,6 +4,8 @@ class Job < ActiveRecord::Base
|
||||||
:name,
|
:name,
|
||||||
presence: true
|
presence: true
|
||||||
|
|
||||||
|
belongs_to :project
|
||||||
|
|
||||||
scope :project, ->(project) { where(project_id: project.id) }
|
scope :project, ->(project) { where(project_id: project.id) }
|
||||||
|
|
||||||
def time_logged
|
def time_logged
|
||||||
|
|
|
@ -21,8 +21,7 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= f.label :project_id %>
|
<%= f.hidden_field :project_id, value: @project.id %>
|
||||||
<%= f.number_field :project_id %>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
Loading…
Reference in New Issue