Mysql Rails有很多:通过的、未定义的方法

Mysql Rails有很多:通过的、未定义的方法,mysql,ruby-on-rails,has-many-through,Mysql,Ruby On Rails,Has Many Through,rails中的多对多关系存在一些问题。我有三个情态动词: 命令 项目 逐项 一个订单有许多项目通过逐项列出,反之亦然 查询Item.find(1).orders可以正常工作,但当我尝试Order.find(1).items时,它返回: NoMethodError: undefined method `items' for #<Order:0x007fcad3bb3258> Order.rb(模型) 类顺序:项 结束 Item.rb(型号) class项:逐项列出 结束 Item

rails中的多对多关系存在一些问题。我有三个情态动词:

  • 命令
  • 项目
  • 逐项
  • 一个订单有许多项目通过逐项列出,反之亦然

    查询Item.find(1).orders可以正常工作,但当我尝试Order.find(1).items时,它返回:

    NoMethodError: undefined method `items' for #<Order:0x007fcad3bb3258>
    
    Order.rb(模型)

    类顺序:项
    结束
    
    Item.rb(型号)

    class项:逐项列出
    结束
    
    Itemized.rb(模型)

    类分项
    不确定是否有干扰,但也有一个商店模式,一个商店有很多订单


    谢谢你的帮助和时间

    如果我查看多对多关联,我会发现

    class医生
    所以我认为这是一个多元化的问题。尝试
    :通过=>:itemized

    什么是
    顺序。查找(1)。itemized
    返回#
    create_table "itemizeds", force: :cascade do |t|
      t.integer  "item_id",    limit: 4
      t.integer  "order_id",   limit: 4
      t.integer  "quantity",   limit: 4
      t.datetime "created_at",           null: false
      t.datetime "updated_at",           null: false
    end
    
    create_table "items", force: :cascade do |t|
      t.string   "title",      limit: 255
      t.datetime "created_at",             null: false
      t.datetime "updated_at",             null: false
    end
    
    create_table "orders", force: :cascade do |t|
      t.integer  "customer_id", limit: 4
      t.integer  "store_id",    limit: 4
      t.integer  "order_id",    limit: 4
      t.datetime "created_at",                                    null: false
      t.datetime "updated_at",                                    null: false
      t.decimal  "price",                 precision: 8, scale: 2
      t.decimal  "discount",              precision: 8, scale: 2
    end
    
    class Order < ActiveRecord::Base
      has_many :itemized
      has_many :items, :through => :itemized
    end
    
    class Item < ActiveRecord::Base
      has_many :itemized
      has_many :orders, :through => :itemized
    end
    
    class Itemized < ActiveRecord::Base
      belongs_to :item
      belongs_to :order
    end
    
    class Physician < ActiveRecord::Base
      has_many :appointments
      has_many :patients, through: :appointments
    end
    
    class Appointment < ActiveRecord::Base
      belongs_to :physician
      belongs_to :patient
    end
    
    class Patient < ActiveRecord::Base
      has_many :appointments
      has_many :physicians, through: :appointments
    end