demarches-normaliennes/app/models/dossier.rb

26 lines
514 B
Ruby
Raw Normal View History

2015-08-10 11:05:06 +02:00
class Dossier < ActiveRecord::Base
has_one :etablissement
has_one :entreprise
2015-08-18 13:52:00 +02:00
has_one :cerfa
has_many :pieces_jointes
2015-08-14 14:05:09 +02:00
belongs_to :formulaire
2015-08-10 11:05:06 +02:00
has_many :commentaires
delegate :siren, to: :entreprise
delegate :siret, to: :etablissement
delegate :types_piece_jointe, to: :formulaire
2015-08-18 14:22:16 +02:00
before_create :build_default_cerfa
def get_pj piece_jointe_id
pieces_jointes.where(type_piece_jointe_id: piece_jointe_id).last
end
2015-08-18 14:22:16 +02:00
private
def build_default_cerfa
build_cerfa
true
end
2015-08-10 11:05:06 +02:00
end