lib/devise/models/authenticatable.rb in devise-3.5.10 vs lib/devise/models/authenticatable.rb in devise-4.0.0.rc1
- old
+ new
@@ -251,10 +251,14 @@
find_or_initialize_with_errors([attribute], { attribute => value }, error)
end
# Find or initialize a record with group of attributes based on a list of required attributes.
def find_or_initialize_with_errors(required_attributes, attributes, error=:invalid) #:nodoc:
- attributes = attributes.slice(*required_attributes).with_indifferent_access
+ attributes = if attributes.respond_to? :permit
+ attributes.slice(*required_attributes).permit!.to_h.with_indifferent_access
+ else
+ attributes.with_indifferent_access.slice(*required_attributes)
+ end
attributes.delete_if { |key, value| value.blank? }
if attributes.size == required_attributes.size
record = find_first_by_auth_conditions(attributes)
end