我对paperclip gem有一些问题。当我尝试在我的应用程序中添加记录时,我收到错误:http://postimg.org/image/xy0stdctd/
当我添加没有图片上传的记录时,一切都很好。
控制器
def create
@user = User.new
end
def made
@user = User.new(user_params)
if @user.save
redirect_to(action:'index' )
else
render ('index')
end
end
def user_params
params.require(:user).permit(:avatar, :name)
end
视图
<%= form_for :user, url: {action: 'made'}, :html => { :multipart => true } do |form| %>
<%= form.text_field :name %>
<br>
<%= form.file_field :avatar %>
<br>
<%= form.submit "dodaj" %>
<% end %>
在终端我有
呈现C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/_source.erb(1.0ms) 呈现C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb(8.0ms) 渲染C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb(2.0ms) 呈现C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4.2.0/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb救援/ 布局(130.0ms) 无法使用内容类型multipart / form-dataAllowed内容类型呈现控制台:[#,#,#]