NoMethodError:#<ActiveRecord :: Associations :: CollectionProxy []>的未定义方法'attributes'

我在将作者对象保存到数据库中时遇到问题。昨天工作正常,所以我不太确定问题出在哪里。

以下是文件:

author.rb

#
# Table name: authors
#
#  id         :integer          not null,primary key
#  name       :string           not null
#  website    :string
#  influences :string
#  bio        :text             not null
#  died       :date
#  created_at :datetime         not null
#  updated_at :datetime         not null
#  birthday   :date             not null
#  photo      :string
#

class Author < ApplicationRecord
  mount_uploader :photo,PhotoUploader

  has_many :books
  has_many :genres,through: :books,source: :genres

  validates :name,presence: true,length: { in: 2..30 }
  validates :bio,presence: true
  validates :birthday,presence: true
  validates :genres,uniqueness: true

end

让我知道是否应该添加任何其他文件,在创建用户方面没有问题-到目前为止,似乎与作者无关。

谢谢!

heminminzjl 回答:NoMethodError:#<ActiveRecord :: Associations :: CollectionProxy []>的未定义方法'attributes'

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3143502.html

大家都在问