未处理的服务器错误!!! 属性 的未知属性 'image'

Unhandled Server Error!!! unknown attribute 'image' for Property

我正在努力解决这个问题。我使用 React Js 作为前端,使用 Ruby on Rails 作为后端。我将一些值从 React 端传递给 Ruby on Rails 进行处理。该值通过 API 和 cycle.js 传递。基本上,我正在做的是 1) 将图像转换为 Base64, 2) 使用 PaperlipProperty、[=39 添加图像=] 3) 在服务器中存储Base64字符串。 错误是:

 Unhandled Server Error!!!
 unknown attribute 'image' for Property.

这是后端代码:

property.rb

 class Property < ActiveRecord::Base
 include PropertySharedMethods
 has_many :property_images, as: :imageable

property_image.rb

 class PropertyImage < ActiveRecord::Base
 belongs_to :imageable, polymorphic: true, optional: true

 has_attached_file :image
 # Validate content type
 validates_attachment_content_type :image, :content_type => /\Aimage/

所以,property_image 是多态的。图像上传将上传到 AWS。对于前端,API 请求成功,但我不知道我的后端代码有什么问题导致了这个错误。

请帮忙。谢谢。

您需要检查您的控制器是否有允许的参数,您可能忘记将图像添加到允许的参数列表中,例如:params.require(:property_image).permit(:image)