Add dependent destroy on has_xxx models
This commit is contained in:
parent
72043dbe56
commit
1551ae82cd
6 changed files with 19 additions and 9 deletions
|
@ -10,13 +10,15 @@ class Dossier < ActiveRecord::Base
|
|||
has_one :etablissement, dependent: :destroy
|
||||
has_one :entreprise, dependent: :destroy
|
||||
has_one :cerfa, dependent: :destroy
|
||||
|
||||
has_many :pieces_justificatives, dependent: :destroy
|
||||
has_many :champs, dependent: :destroy
|
||||
has_many :quartier_prioritaires, dependent: :destroy
|
||||
has_many :cadastres, dependent: :destroy
|
||||
has_many :commentaires, dependent: :destroy
|
||||
|
||||
belongs_to :procedure
|
||||
belongs_to :user
|
||||
has_many :commentaires, dependent: :destroy
|
||||
|
||||
delegate :siren, to: :entreprise
|
||||
delegate :siret, to: :etablissement, allow_nil: true
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
class PieceJustificative < ActiveRecord::Base
|
||||
belongs_to :dossier
|
||||
belongs_to :type_de_piece_justificative
|
||||
|
||||
delegate :api_entreprise, :libelle, to: :type_de_piece_justificative
|
||||
|
||||
alias_attribute :type, :type_de_piece_justificative_id
|
||||
|
||||
mount_uploader :content, PieceJustificativeUploader
|
||||
|
||||
def empty?
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
class Procedure < ActiveRecord::Base
|
||||
has_many :types_de_piece_justificative
|
||||
has_many :types_de_champ
|
||||
has_many :dossiers
|
||||
has_one :module_api_carto
|
||||
has_many :types_de_piece_justificative, dependent: :destroy
|
||||
has_many :types_de_champ, dependent: :destroy
|
||||
has_many :dossiers, dependent: :destroy
|
||||
|
||||
has_one :module_api_carto, dependent: :destroy
|
||||
|
||||
belongs_to :administrateur
|
||||
|
||||
accepts_nested_attributes_for :types_de_champ,:reject_if => proc { |attributes| attributes['libelle'].blank? }, :allow_destroy => true
|
||||
accepts_nested_attributes_for :types_de_piece_justificative, :reject_if => proc { |attributes| attributes['libelle'].blank? }, :allow_destroy => true
|
||||
accepts_nested_attributes_for :module_api_carto
|
||||
belongs_to :administrateur
|
||||
|
||||
mount_uploader :logo, ProcedureLogoUploader
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@ class TypeDeChamp < ActiveRecord::Base
|
|||
}
|
||||
|
||||
belongs_to :procedure
|
||||
has_many :champ
|
||||
|
||||
has_many :champ, dependent: :destroy
|
||||
|
||||
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||
validates :type_champ, presence: true, allow_blank: false, allow_nil: false
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
class TypeDePieceJustificative < ActiveRecord::Base
|
||||
has_many :pieces_justificatives
|
||||
has_many :pieces_justificatives, dependent: :destroy
|
||||
|
||||
belongs_to :procedure
|
||||
|
||||
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||
|
|
|
@ -7,7 +7,7 @@ class User < ActiveRecord::Base
|
|||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
has_many :dossiers
|
||||
has_many :dossiers, dependent: :destroy
|
||||
|
||||
def self.find_for_france_connect_particulier user_info
|
||||
|
||||
|
|
Loading…
Reference in a new issue