こんにちは、私は一度他との関係を持つモデルを作成しましたが、レールの複数化オプションに驚いています。つまり。
次のようなモデルを作成します。
rails g model Report name:string....
私がしたように:
rails g model Patient name:string...
rails g model Doctor name:string....
Doctor には多くの患者がいるので、コンソールに移動して次のように入力します。
patient.doctor => gives me the doctor from a patient
doctor.patients => gives me all patients from a doctor (note patients in plural)
そして、これが奇妙なことです。私はレポートでまったく同じことをしましたが、コマンドがあると思います:
patient.reports (note plural)
しかし、これの代わりに、患者のレポートを取得したい場合は、次のことを行う必要があります。
patient.report (note singular)... AND IT WORKS!
誰かが私の失明を照らすことができますか?