I want to learn that there is a native way make building normal and
mandatory belongs_to associations. Let give a simple example, I have two
models, first one is Tenant, second is User. User belongs to Tenant
mean there is a User.tenant_id. I can create, save or update User Model
without User.tenant_id . I named this is normal belongs_to . What i want
User model can’t update or save if tenant_id = nil.
What is the best solution for this problem.
My schema is
My models are
My migrations are
*Note : *User Model extends from TenantScope model!
I see that rails doesn’t add foreign key at DB layer. There are several
gems for this issue. But i can’t understand why we don’t add foreign
Why this is a good idea? Is it over performance or portability?
Onur zgr ZKAN
**lab2023 - internet teknolojileri
Adres: Pamukkale Teknoloji Gelitirme Blgesi
dari Bina B-Blok Z13 Knkl / Denizli / TRKYE
Telefon: +90 258 215 50 10 - E-posta: [email protected]