图片没有上传

问题描述 投票:1回答:1

我一直试图在RoR上传图片,但图片没有上传。我的控制器的代码片段是

def employee_params_with_pic
    params.require(:employee).permit( :phone, :personal_email, :address, :picture)
  end

我视图中上传图片的代码是

<div>
    <%= f.label :Display %>
    <%= f.file_field :picture %>
</div>

当我选择要上传的图片时,以下结果是The filename of the picture

删除数据库的空字段。相反,它没有显示值no values

图片没有出现在它应该显示的字段中。

显示图像的视图是

<span class="content">
    <%= image_tag @employee.details.url if @employee.picture? %>
</span>
html css ruby-on-rails sqlite
1个回答
1
投票

它应该是这样的:

<%= image_tag @employee.picture_url if @employee.picture? %>
© www.soinside.com 2019 - 2024. All rights reserved.