latest changes introduced with cursor
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
class ProjectsController < ApplicationController
|
||||
before_action :set_project, only: %i[ show edit update destroy ]
|
||||
before_action :set_collections, only: %i[new edit create update]
|
||||
|
||||
# GET /projects or /projects.json
|
||||
def index
|
||||
@@ -74,6 +75,11 @@ class ProjectsController < ApplicationController
|
||||
@project = Project.find(params[:id])
|
||||
end
|
||||
|
||||
def set_collections
|
||||
@clients = Client.order(:company_name, :lastname, :firstname).to_a
|
||||
@projects = Project.order(:name).to_a
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def project_params
|
||||
params.require(:project).permit(
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<% [:client, :owner, :builder].each do |role| %>
|
||||
<div>
|
||||
<%= sp_form.label "#{role}_id", "Select Existing #{role.capitalize}" %>
|
||||
<%= sp_form.collection_select "#{role}_id", Client.all, :id, -> (client) { "#{client.company_name} (#{client.lastname}, #{client.firstname})" }, prompt: "Select #{role.capitalize}" %>
|
||||
<%= sp_form.collection_select "#{role}_id", clients, :id, :display_name, prompt: "Select #{role.capitalize}" %>
|
||||
|
||||
<fieldset>
|
||||
<legend>Or Create New <%= role.capitalize %></legend>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<h1>Editing project</h1>
|
||||
|
||||
<%= render "form", project: @project %>
|
||||
<%= render "form", project: @project, clients: @clients %>
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<h1>New project</h1>
|
||||
|
||||
<div id="projects">
|
||||
<%= render "form", project: @project %>
|
||||
<%= render "form", project: @project, clients: @clients %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user