model callbacks fail if referenced models not prepended with `::`
Expected behavior
Referencing related models in callbacks doesn't cause any issues.
Actual behavior
I have a method in a model Behavior that creates related records that is called in an after_create callback.
if EngagementQuestion.count.zero?
EngagementQuestion.create!(
position: 0,
behavior: self,
organization: Organization.current
)
else
EngagementQuestion.create!(
position: EngagementQuestion.maximum(:position) + 1,
behavior: self,
organization: Organization.current
)
end
Whenever I create the behavior using forest, in development I get ArgumentError Exception: A copy of Behavior has been removed from the module tree but is still active!, in production I just get "Unknown Error". I have noticed that if I prepend every model with :: (i.e. ::EngagementQuestion) I can at least get past this, but it still fails because the behavior contains translations that are automatically created by the globalize gem in a separate callback, and this fails as well (I'm assuming for the same reason)
Context
- Package Version: 6.6.2
- Rails Version: 5.2
- Database Dialect: PostgreSQL
- Database Version: 12
I can confirm that this does not happen in Rails 6.1