Update paths

Use the much nicer /project/:project_id/jobs format
This commit is contained in:
Trevor Vallender 2023-11-26 20:52:05 +00:00
parent 1c032cc42e
commit d83c3b3e48
8 changed files with 15 additions and 13 deletions

View File

@ -19,7 +19,7 @@ class JobsController < ApplicationController
def update def update
if @job.update(remove_empty_time_budgets(job_params)) if @job.update(remove_empty_time_budgets(job_params))
redirect_to job_path(@job, project_id: @job.project.id) redirect_to project_job_path(@job.project, @job)
else else
render :edit render :edit
end end
@ -27,7 +27,7 @@ class JobsController < ApplicationController
def create def create
if @job = Job.create(job_params) if @job = Job.create(job_params)
redirect_to job_path(@job, project_id: @job.project.id) redirect_to project_job_path(@job.project, @job)
else else
render :edit render :edit
end end
@ -36,7 +36,7 @@ class JobsController < ApplicationController
def destroy def destroy
@project = @job.project @project = @job.project
if @job.destroy if @job.destroy
redirect_to jobs_path(project_id: @project.id) redirect_to project_jobs_path(@project)
else else
render :show render :show
end end

View File

@ -49,6 +49,6 @@ class Job < ActiveRecord::Base
def to_s def to_s
ActionView::Base.send(:include, Rails.application.routes.url_helpers) ActionView::Base.send(:include, Rails.application.routes.url_helpers)
ActionController::Base.helpers.link_to name, ActionController::Base.helpers.job_path(self, project_id: project.id) ActionController::Base.helpers.link_to name, ActionController::Base.helpers.project_job_path(project, self)
end end
end end

View File

@ -1,5 +1,5 @@
<tr> <tr>
<td><%= link_to job.name, job_path(job, project_id: job.project_id) %></td> <td><%= link_to job.name, project_job_path(job.project, job) %></td>
<td><%= format_date(job.starts_on) %></td> <td><%= format_date(job.starts_on) %></td>
<td><%= format_date(job.ends_on) %></td> <td><%= format_date(job.ends_on) %></td>
<td><%= job.project_id %></td> <td><%= job.project_id %></td>

View File

@ -1,5 +1,5 @@
<% html_title "Edit #{@job.name}" %> <% html_title "Edit #{@job.name}" %>
<h2>Edit <%= @job.name %></h2> <h2>Edit <%= @job.name %></h2>
<%= render partial: "form", locals: { form_target: job_path(@job, project_id: @job.project) } %> <%= render partial: "form", locals: { form_target: project_job_path(@job.project, @job) } %>

View File

@ -1,6 +1,6 @@
<% html_title "Jobs" %> <% html_title "Jobs" %>
<div class="contextual"> <div class="contextual">
<%= link_to 'New job', new_job_path(project_id: @project.id), class: "icon icon-add new-job" %> <%= link_to 'New job', new_project_job_path(project: @project), class: "icon icon-add new-job" %>
</div> </div>
<h2>Jobs</h2> <h2>Jobs</h2>

View File

@ -1,3 +1,3 @@
<h2><%= link_to "Jobs", jobs_path(project_id: @project.id) %> » New</h2> <h2><%= link_to "Jobs", project_jobs_path(@project) %> » New</h2>
<%= render partial: "form", locals: { form_target: jobs_path } %> <%= render partial: "form", locals: { form_target: project_jobs_path(@project) } %>

View File

@ -1,9 +1,9 @@
<% html_title @job.name %> <% html_title @job.name %>
<div class="contextual"> <div class="contextual">
<%= link_to 'Edit', edit_job_path(project_id: @project.id), class: "icon icon-edit edit-job" %> <%= link_to 'Edit', edit_project_job_path(@project, @job), class: "icon icon-edit edit-job" %>
<%= actions_dropdown do %> <%= actions_dropdown do %>
<%= copy_object_url_link(job_url(@job, project_id: @project.id, only_path: false)) %> <%= copy_object_url_link(project_job_url(@project, @job, only_path: false)) %>
<%= link_to "Delete job", job_path(@job), data: { confirm: "Are you sure you want to delete this job?" }, method: :delete, class: 'icon icon-del' %> <%= link_to "Delete job", project_job_path(@project, @job), data: { confirm: "Are you sure you want to delete this job?" }, method: :delete, class: 'icon icon-del' %>
<% end %> <% end %>
</div> </div>
<h2>Job #<%= @job.id %></h2> <h2>Job #<%= @job.id %></h2>

View File

@ -1 +1,3 @@
resources :jobs resources :projects do
resources :jobs
end