导致HasManyThroughCantAssociateThroughHasOneOrManyReflection的保存错误

时间:2018-01-31 19:39:42

标签: ruby-on-rails

由于某种原因,我无法理解我做错了什么。保存项目时出错。我需要改变什么?

Active_cord :: HasManyThroughCantAssociateThroughHasOneOrManyReflection发生在user_boards#show:

无法修改关联'Project#todos',因为源反射类'Todo'通过:has_many与'List'相关联。

class Project < ApplicationRecord
  has_many :lists, -> { order(position: :asc) }, dependent: :destroy
  has_many :todos, through: :lists
  has_many :labels, dependent: :destroy
  has_many :todo_lists, -> { where('status = "active"').order(position: :asc) }, :class_name => 'TodoList', dependent: :destroy


class Todo < ApplicationRecord
  belongs_to :list
  acts_as_list scope: :list, add_new_at: :top
  has_one :project, through: :list

class List < ApplicationRecord
  belongs_to :project
  has_many :todos, -> { order(position: :asc) }, dependent: :destroy
  has_many :todo_lists, dependent: :destroy
  has_many :active_todo_lists, -> { where('status = "active"').order(position: :asc) }, :class_name => 'TodoList'
  has_many :active_todos, -> { where('status = "active"').order(position: :asc) }, :class_name => 'Todo'
  acts_as_list scope: :project

0 个答案:

没有答案