lundi 30 janvier 2017

Rails best way (or best practices)

Hi I have a model which I don't know how to focus the following issue:

I have been reading the following posts

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