Ruby on Rails: how to get error messages from a child resource displayed?

后端 未结 8 1397
谎友^
谎友^ 2020-12-12 16:58

I\'m having a difficult time understanding how to get Rails to show an explicit error message for a child resource that is failing validation when I render an XML template.

8条回答
  •  隐瞒了意图╮
    2020-12-12 17:45

    I see a problem in the posted code. add_student is a class method of class School, so self will point to the class object School instead of an instance object of class School. The line students << s will not add the record s to the record school because of this.

    I don't know if this is causing your error message problem, but I think this will keep the code from working properly.

提交回复
热议问题