Validation failed Class must exist

后端 未结 8 1506
面向向阳花
面向向阳花 2020-12-13 17:30

I have been (hours) trouble with associations in Rails. I found a lot of similar problems, but I couldn\'t apply for my case:

City\'s class:

class Ci         


        
8条回答
  •  Happy的楠姐
    2020-12-13 18:04

    Try the following:

    belongs_to :city, optional: true
    

    According to the new docs:

    4.1.2.11 :optional

    If you set the :optional option to true, then the presence of the associated object won't be validated. By default, this option is set to false.

提交回复
热议问题