citusdata / citusdata/activerecord-multi-tenant
MultiTenant.without does not work for a polymorphic relationship
Open
- Dominant language
- Ruby
- Stars
- 759
- Forks
- 113
- PR merge metrics
- No merged PRs in 30d
Description
In the following code.
👍 the `Visit.find_by` query does not add account_id where condition, which is perfect
👎 but, during `visit.save!`, Rails does a `Product` lookup, to which an account_id where condition is added
```ruby
MultiTenant.without do
visit = Visit.find_by(visitable_type: "Product", visitable_id: 1)
visit.last_visit_at = Time.current
visit.save!
end
class Visit < ApplicationRecord
multi_tenant :account
belongs_to :visitable, polymorphic: true
end
class Product < ApplicationRecord
multi_tenant :account
end
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.