Not doing so has a few gotchas when working with relations, particularly with records which are not stored in the database. I'm excluding the related content file because it's got a very peculiar relationship with itself: the `has_one :opposite_related_content` has no inverse; the relation itself is its inverse. It's a false positive since the inverse condition is true: ``` content.opposite_related_content.opposite_related_content.object_id == content.object_id ```
12 lines
228 B
Ruby
12 lines
228 B
Ruby
module StatsVersionable
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
has_one :stats_version, as: :process, inverse_of: :process
|
|
end
|
|
|
|
def find_or_create_stats_version
|
|
stats_version || create_stats_version
|
|
end
|
|
end
|