Last active
November 27, 2018 18:01
-
-
Save ritikesh/5ce55c89300c9ce0a8f310463d5ed369 to your computer and use it in GitHub Desktop.
Model Concern for a multi-tenant rails app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module BelongsToTenant | |
extend ActiveSupport::Concern | |
included do | |
belongs_to :tenant | |
default_scope { | |
Tenant.current ? where(tenant_id: Tenant.current.id) : where(nil) | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment