diff options
author | Dennis Schubert <mail@dennis-schubert.de> | 2020-02-09 19:38:19 +0300 |
---|---|---|
committer | Benjamin Neff <benjamin@coding4coffee.ch> | 2020-02-12 01:53:14 +0300 |
commit | 25e9728fae9646294c3bd14e8d9377925528abf6 (patch) | |
tree | b8ece7d162898fe93700e2c262ab05f827e6b5c2 /app | |
parent | 93b0e1eb22a1cbc37ae033f007d73c0ae2da8e26 (diff) |
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.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/person.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/app/models/person.rb b/app/models/person.rb index 8745a1179..64746200e 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -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 |