Skip to content
Extraits de code Groupes Projets
Non vérifiée Valider 25e9728f rédigé par Dennis Schubert's avatar Dennis Schubert Validation de Benjamin Neff
Parcourir les fichiers

Do not depend on the default parameter being set in Person#initialize.

 ActiveRecord 5.2.x occasionally calls with a nil parameter explicitly provided, so using default arguments does not work.
parent 93b0e1eb
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -185,6 +185,8 @@ class Person < ApplicationRecord
# end
# will not work! The nil profile will be overriden with an empty one.
def initialize(params={})
params = {} if params.nil?
profile_set = params.has_key?(:profile) || params.has_key?("profile")
params[:profile_attributes] = params.delete(:profile) if params.has_key?(:profile) && params[:profile].is_a?(Hash)
super
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter