2011/11/11 Onur Özgür ÖZKAN <[email protected]>: > Hi Folks, > First Question > > 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 which > 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 is > User model can't update or save if tenant_id = nil.
Use a validation in the User model. See the Rails Guide on Active Record Validations and Callbacks. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

