Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Can';t为以下项创建别名:通过_Ruby On Rails - Fatal编程技术网

Ruby on rails Can';t为以下项创建别名:通过

Ruby on rails Can';t为以下项创建别名:通过,ruby-on-rails,Ruby On Rails,这是我的迁移代码: 1.用户 create_table :users do |t| t.string :name t.string :password t.string :department t.timestamps end 2.策略 create_table :ploys do |t| t.string :name t.string :state t.string :descri

这是我的迁移代码:

1.用户

    create_table :users do |t|
      t.string :name
      t.string :password
      t.string  :department

      t.timestamps
    end
2.策略

    create_table :ploys do |t|
      t.string :name
      t.string :state
      t.string :description
      t.string :location
      t.float  :spend

      t.references :creator, index: true, class_name: "User"

      t.timestamps
    end
3.与会者

   def change
    create_table :participants do |t|
      t.belongs_to :ploy
      t.belongs_to :user

      t.timestamps
    end
这是我的型号代码:

class User < ActiveRecord::Base
  has_one :create_ploys, class_name: "Ploy"

  has_many :participants
  has_many :ploys, through: :participants, source: :join_ploys
end

class Ploy < ActiveRecord::Base
  belongs_to :creator, class_name: "User"

  has_many :participants
  has_many :users, through: :participants, source: "joiners"
end

class Participant < ActiveRecord::Base
  belongs_to :user
  belongs_to :ploy
end
class用户
当我调用user.join\u ploys,但给我一个错误:NoMethodError:undefined方法'join\u ploys'


因此,我认为:source可能有问题,但我不知道该怎么做。

那么,您在哪里定义加入者和加入策略的模型或关联?您不能只创建一个:source而不定义它是什么。查看此文件,以便: