在RoR中生成模型时显示的错误,模型中参数的错误编号
问题描述:
我是RoR中的新成员。我正在学习模型并为我的应用程序生成模型,它是关联。控制台产生的错误,当我尝试:在RoR中生成模型时显示的错误,模型中参数的错误编号
$轨控制台
mypath.rbenv /版本/ 2.3.3/lib中/红宝石/宝石/ 2.3.0 /宝石/ ActiveRecord的-5.1.3/LIB/active_record/associations.rb:1395:在 `的has_many':错误的参数数目(4给出,预期1..3) (引发ArgumentError)
和多行的错误,但是这个人是关键我想。
答
解决了这个问题,我写在同一行不同的联想这是不正确的:
错误:
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :questions, :answers, :comments, :votes
end
正确:
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :questions
has_many :answers
has_many :comments
has_many :votes
end