How to create an association between two rails models

后端 未结 5 1164
南笙
南笙 2021-01-16 12:07

This is a newbie question, but I\'m still learning how to create an association between two models in rails. I have a user model and a journal_entry model. The journal entri

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-16 12:48

    you have it right this time. You added the user association to the journal model which loads the user in the controller before displaying it in the view. You do need the hidden fields in your form which you added, since you are using a stateless protocol. On the update/create action, double check that the user posting is the user using and save.

提交回复
热议问题