We've moved discussions to Discord

ActsAsTenant and joins on has_many? Failing with "Object doesn't support #inspect" in prod.

Donal O Duibhir
Am just trying to find accounts with > 0 buckets (or technically, I really want accounts with agents > 0). This never was a problem on other non-ActsAsTenant projects. I've even tried setting the current_tenant and iterating, but that's worse and also fails.
Loading production environment (Rails
irb(main):001:1* ActsAsTenant.without_tenant do
irb(main):002:1* Account.joins(:buckets).group('buckets.id').to_sql
irb(main):003:0> end
=> "SELECT \"accounts\".* FROM \"accounts\" INNER JOIN \"buckets\" ON \"buckets\".\"account_id\" = \"accounts\".\"id\" GROUP BY \"buckets\".\"id\""
irb(main):004:1* ActsAsTenant.without_tenant do
irb(main):005:1* Account.joins(:buckets).group('buckets.id')
irb(main):006:0> end
*(Object doesn't support #inspect)*. <=================
    class Account < ApplicationRecord
     has_many :buckets, dependent: :destroy
     has_many :agents, through: :buckets

     class Bucket < ApplicationRecord
       acts_as_tenant :account
       belongs_to :account, autosave: true
       has_many :agents, dependent: :destroy, autosave: true

    class Agent < ApplicationRecord
       acts_as_tenant :account
       belongs_to :bucket, autosave: true
I feel like I'm missing something obvious/stupid... something to do with the default_scope but I am effectively turning off ActsAsTenant with the .without_tenant code block... and even the joins query with distinct doesn't work?

You’re not receiving notifications from this thread.