From 0b8933ea1fed938c26f8a3ceac23364191620c41 Mon Sep 17 00:00:00 2001 From: Cody Krieger Date: Sat, 21 Jan 2023 11:26:30 -0500 Subject: [PATCH] allow 'touch' option to be passed through to belongs_to association (#306) --- README.md | 2 +- lib/acts_as_tenant/model_extensions.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6c3c80b..7210821 100644 --- a/README.md +++ b/README.md @@ -282,7 +282,7 @@ end ``` You can add the following `belongs_to` options to `acts_as_tenant`: -`:foreign_key, :class_name, :inverse_of, :optional, :primary_key, :counter_cache` +`:foreign_key, :class_name, :inverse_of, :optional, :primary_key, :counter_cache, :polymorphic, :touch` Example: `acts_as_tenant(:account, counter_cache: true)` diff --git a/lib/acts_as_tenant/model_extensions.rb b/lib/acts_as_tenant/model_extensions.rb index 4378b49..5bd113a 100644 --- a/lib/acts_as_tenant/model_extensions.rb +++ b/lib/acts_as_tenant/model_extensions.rb @@ -10,7 +10,7 @@ def acts_as_tenant(tenant = :account, **options) ActsAsTenant.add_global_record_model(self) if options[:has_global_records] # Create the association - valid_options = options.slice(:foreign_key, :class_name, :inverse_of, :optional, :primary_key, :counter_cache, :polymorphic) + valid_options = options.slice(:foreign_key, :class_name, :inverse_of, :optional, :primary_key, :counter_cache, :polymorphic, :touch) fkey = valid_options[:foreign_key] || ActsAsTenant.fkey pkey = valid_options[:primary_key] || ActsAsTenant.pkey polymorphic_type = valid_options[:foreign_type] || ActsAsTenant.polymorphic_type