Fix job redirects
This commit is contained in:
parent
6b1646e180
commit
73d3066b74
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue