Add a method to speed up a conditional statement
This commit is contained in:
parent
0a8ac645d8
commit
79eccb2de0
2 changed files with 5 additions and 1 deletions
|
@ -92,6 +92,10 @@ class Dossier < ActiveRecord::Base
|
|||
unreaded_notifications.order("created_at ASC").first
|
||||
end
|
||||
|
||||
def was_piece_justificative_uploaded_for_type_id?(type_id)
|
||||
pieces_justificatives.where(type_de_piece_justificative_id: type_id).count > 0
|
||||
end
|
||||
|
||||
def retrieve_last_piece_justificative_by_type(type)
|
||||
pieces_justificatives.where(type_de_piece_justificative_id: type).last
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
- if tpj.api_entreprise
|
||||
%span.text-success{ id: "piece_justificative_#{tpj.id}" } Nous l'avons récupéré pour vous.
|
||||
- else
|
||||
- if dossier.retrieve_last_piece_justificative_by_type(tpj.id).nil?
|
||||
- if !dossier.was_piece_justificative_uploaded_for_type_id?(tpj.id)
|
||||
= file_field_tag "piece_justificative_#{tpj.id}", accept: PieceJustificative.accept_format, :max_file_size => 6.megabytes
|
||||
- else
|
||||
%span.btn.btn-sm.btn-file.btn-success
|
||||
|
|
Loading…
Add table
Reference in a new issue