undefined方法`relation_delegate_class'

时间:2018-04-29 19:00:12

标签: ruby-on-rails

我有三种模式:

class Course < ApplicationRecord
  has_many :sections
end

class Section < ApplicationRecord
  belongs_to :course
  has_many :section_files
end

class SectionFile < ApplicationRecord
  belongs_to :section
end

每当我尝试拨打@course.sections时,都会收到错误undefined method 'relation_delegate_class' for Course::Section:Module

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

修复了我在Section

上指定类名的问题
Class Course < ApplicationRecord
  has_many :sections, class_name: "::Section"
end

虽然@section.section_files似乎无需明确说明类名