ifad / chronomodel

Temporal PostgreSQL (9.4+) system with "flashback" framework for ActiveRecord (7.0+)
MIT License
194 stars 21 forks source link

Deprecation warning when running specs on rails edge #278

Closed tagliala closed 6 months ago

tagliala commented 6 months ago
DEPRECATION WARNING: The `Bar#foo` inverse association could have been automatically inferred as `Foo#bars` but wasn't because `automatically_invert_plural_associations` is disabled.

If automatic inference is intended, you can consider enabling `config.active_record.automatically_invert_plural_associations`.

If automatic inference is not intended, you can silence this warning by defining the association with `inverse_of: false`. (called from block in <module:TimeMachine> at /home/runner/work/chronomodel/chronomodel/spec/support/time
tagliala commented 6 months ago

Ref:

tagliala commented 6 months ago

The following code:

    class ::Bar < ActiveRecord::Base
      include ChronoModel::TimeMachine

      belongs_to :foo
    end

    class ::Foo < ActiveRecord::Base
      include ChronoModel::TimeMachine

      has_many :bars
    end

has this deprecation:

DEPRECATION WARNING: The `Bar#foo` inverse association could have been automatically inferred as `Foo#bars` but wasn't because `automatically_invert_plural_associations` is disabled.

If automatic inference is intended, you can consider enabling `config.active_record.automatically_invert_plural_associations`.

If automatic inference is not intended, you can silence this warning by defining the association with `inverse_of: false`. 

After reading rails/rails#50284, I do not have idea of what is happening.

It is absolutely not clear why one should set

      belongs_to :foo, inverse_of: false

🤷🏼‍♂️