Validation failed Class must exist

后端 未结 8 1519
面向向阳花
面向向阳花 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条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-13 17:59

    This comes a bit late but this is how to turn off this by default in rails 5:

    config/initializers/new_framework_defaults.rb

    Rails.application.config.active_record.belongs_to_required_by_default = false
    

    In case you don't want to add optional: true to all your belongs_to.

    I hope this helps!

提交回复
热议问题