Skip to content

Switch `ApplicationRecord#safe_find_or_create_by` to use Rails 6 method

Stan Hu requested to merge sh-use-rails-create-or-find-by into master

Rails 6 introduced create_or_find_by (https://api.rubyonrails.org/classes/ActiveRecord/Relation.html#method-i-create_or_find_by), which implements ApplicationRecord#safe_find_or_create_by in a slightly clearer way. Switch to this under the hood and update the documentation to recommend using the Rails 6 method directly.

Edited by Stan Hu

Merge request reports

Loading