DRY CLIENT_FIELDS

This commit is contained in:
Stefan Tollkühn
2025-07-21 16:57:37 +02:00
parent 15604327a2
commit 347bdf370b

View File

@@ -64,6 +64,9 @@ class ProjectsController < ApplicationController
end
private
CLIENT_FIELDS = [:company_name, :firstname, :lastname, :streetname, :zipcode, :city, :country, :email, :phone]
# Use callbacks to share common setup or constraints between actions.
def set_project
@project = Project.find(params.expect(:id))
@@ -75,9 +78,9 @@ class ProjectsController < ApplicationController
:name, :email, :short_name,
subprojects_attributes: [
:id, :subproject_name, :client_id, :owner_id, :builder_id, :_destroy,
client_attributes: [:company_name, :firstname, :lastname, :streetname, :zipcode, :city, :country, :email, :phone],
owner_attributes: [:company_name, :firstname, :lastname, :streetname, :zipcode, :city, :country, :email, :phone],
builder_attributes: [:company_name, :firstname, :lastname, :streetname, :zipcode, :city, :country, :email, :phone]
client_attributes: CLIENT_FIELDS,
owner_attributes: CLIENT_FIELDS,
builder_attributes: CLIENT_FIELDS
]
)
end