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 6.1.4.1)
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)*. <=================
and
    class Account < ApplicationRecord
     ...
     has_many :buckets, dependent: :destroy
     has_many :agents, through: :buckets
     ....
     end

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

    class Agent < ApplicationRecord
       acts_as_tenant :account
       belongs_to :bucket, autosave: true
       ...
     end
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?





Notifications
You’re not receiving notifications from this thread.