blob: c4e310e638d69f66a393260942a02cf32dc473a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
def self.id_in(ids)
where(id: ids)
end
def self.safe_find_or_create_by(*args)
transaction(requires_new: true) do
find_or_create_by(*args)
end
rescue ActiveRecord::RecordNotUnique
retry
end
end
|