你好我是rails的新手我想在我的表单中使用paperclip gem上传图片,但它显示错误。
1 error prohibited this cuber from being saved:
Gravatar translation missing:en.activerecord.errors.models.cuber.attributes.gravatar.spoofed_media_type
我在git://github.com/thoughtbot/paperclip.git和版本3.5.3中捆绑了最新版本的宝石,我得到了这个错误 仍然显示错误 我的cuber.rb文件是
class Cuber < ActiveRecord::Base
has_attached_file :gravatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
validates_attachment_content_type :gravatar, :content_type => /\Aimage\/.*\Z/
end
我的表格是
<%= form_for @cuber , :html => { :multipart => true } do |f| %>
<% if @cuber.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@cuber.errors.count, "error") %> prohibited this cuber from being saved:</h2>
<ul>
<% @cuber.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<%= f.file_field :gravatar %>
<div class="field">
<%= f.label :name %><br>
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :surname %><br>
<%= f.text_field :surname %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
答案 0 :(得分:2)
validates_attachment_content_type :gravatar, :content_type => /\Aimage\/.*\Z/
仅在Paperclip V4
在此版本之前,您不需要内容类型验证。我建议升级到Paperclip V4,这个错误应解决