-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Détecte l'erreur de "code campagne inconnu" proprement
Le code précédent détournait "astucieusement" le message d'erreur du validateur de la présence de la campagne quand le code campagne n'était pas connu. Ceci posait un problème pour l'édition d'un évaluation qui indiquait "code campagne inconnu" quand on ne renseignait pas de campagne. On s'est pris les pied dans le tapis et nous retournions "doit être rempli" aux évalué·es quand il ou elle remplissaint un code campagne inconnu. De plus, cette astuce nous a fait perdre un temps fou pour retrouver le problème.
- Loading branch information
1 parent
7a3ec01
commit 1ef3eb1
Showing
7 changed files
with
70 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
class GenerateurParamsEvaluation | ||
attr_reader :code_campagne_inconnu, :params | ||
|
||
def initialize(params) | ||
@params = params.permit( | ||
:nom, | ||
:code_campagne, | ||
:email, | ||
:telephone | ||
) | ||
relie_campagne | ||
end | ||
|
||
private | ||
|
||
def relie_campagne | ||
code_campagne = @params.delete('code_campagne') | ||
return if code_campagne.blank? | ||
|
||
campagne = Campagne.find_by code: code_campagne | ||
@code_campagne_inconnu = campagne.nil? | ||
@params['campagne'] = campagne | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters