Implement SubprojectAddresses in Subprojects
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
class Subproject < ApplicationRecord
|
||||
belongs_to :project
|
||||
has_one :subproject_address, dependent: :destroy
|
||||
|
||||
belongs_to :client, class_name: 'Client', optional: true
|
||||
belongs_to :owner, class_name: 'Client', optional: true
|
||||
belongs_to :builder, class_name: 'Client', optional: true
|
||||
belongs_to :subproject_addresses, optional: true
|
||||
|
||||
accepts_nested_attributes_for :client, reject_if: ->(attrs) { attrs['id'].present? || attrs.values.all?(&:blank?) }
|
||||
accepts_nested_attributes_for :owner, reject_if: ->(attrs) { attrs['id'].present? || attrs.values.all?(&:blank?) }
|
||||
accepts_nested_attributes_for :builder, reject_if: ->(attrs) { attrs['id'].present? || attrs.values.all?(&:blank?) }
|
||||
accepts_nested_attributes_for :subproject_addresses, allow_destroy: true, reject_if: ->(attrs) { attrs['id'].present? || attrs.values.all?(&:blank?) }
|
||||
|
||||
|
||||
validates :subproject_name, presence: true
|
||||
validate :client_presence_check
|
||||
|
||||
Reference in New Issue
Block a user