Skip to content

Commit

Permalink
fix init after reload on development
Browse files Browse the repository at this point in the history
On 26fc746, init is not forced to be executed on `to_prepare`. This helps us avoid a connection at startup.
However, things break down after a reload because things like `ExcludedModel.count` don't go through
the `connection` method that we overrode, at least until after we
queried the table name.

Let's make sure that we initialize before using arel too.
  • Loading branch information
fsateler committed May 19, 2020
1 parent 26fc746 commit 901dc80
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/apartment/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ def connection
Apartment::Tenant.init_once
end
end

def arel_table
Apartment::Tenant.init_once
super
end
end
ActiveRecord::Base.singleton_class.prepend ApartmentInitializer

Expand Down

0 comments on commit 901dc80

Please sign in to comment.