1
我有类似下面的嵌套的资源:用户/ 1 /照片/新轨道4强参数嵌套资源
resources :users, only: [] do
resources :photos, except: [:show]
end
我的form_for是这样的:
= form_for([@user, @photo], html: { multipart: true }) do |f|
.inputs
= f.file_field :attached_photo
.actions
= f.submit :submit
我相信问题我有是具有较强的参数:
def photo_params
params.require(:photo).permit(:title, :attached_photo)
end
当我打的形式我得到以下错误提交按钮:
的ActionController :: ParameterMissing在PhotosController#创建 PARAM未发现:照片
我用回形针所以在模型中我有:
has_attached_file :attached_photo
请指教。
什么是您的轨道服务器输出秀PARAMS贴? – jvperrin
如果我为标题添加文本字段。然后参数如下:“photo”=> {“title”=>“”},“commit”=>“submit”,“painter_id”=>“1”看起来:attached_photo没有被传递。 – Brian
即使您使用文件字段上传文件,该文件是否仍然无法传递?我在我的一个应用程序上使用回形针照片上传进行了测试,并且只有在文件字段实际选择了文件时才会包含该参数。 – jvperrin