Hi I have a model which I don't know how to focus the following issue:
I have been reading the following posts
- before_create in rails model
- before_create in user model -- set integer based on email (RAILS)
- Access current_user in model
I have a project where I wan to manage some properties (Assets). I have House, Owner, Company and Users.
The House and the Owner are linked in the DB with a FK so 1 Company has N Owners and 1 Company has N Houses
The model User is linked to Company, so 1 Company has N users.
How can I access to the company_id in the model Users in order to store this ID in the House and in the Owner model when the House and Owner is created?
- Do I have to do it in the controller?
- Do I have to do it in the model?
Thank you
Aucun commentaire:
Enregistrer un commentaire