“.save” only inserts null values in database

前端 未结 3 992
时光说笑
时光说笑 2021-01-15 08:14

I\'m trying to make a RoR application for a Hospital so it has patients, doctors, offices, etc.

The problem I\'m having is that, at the patient \"Sign-up\", I\'m not

3条回答
  •  鱼传尺愫
    2021-01-15 08:29

    Remove the following line in class Patient:

    attr_accessor :name, :pID
    

    What happened was that attr_accessor replaced the two database column attributes :name and :pID (which were automatically generated) with its own, resulting in two virtual attributes, :name and :pID.

    Thus, the virtual attributes were being set and validated instead of the corresponding database attributes, which resulted in no errors yet null values in the database.

提交回复
热议问题