我有一个名为post的模型,我正在尝试使用纸夹宝石为帖子添加图像内容,我在本地运行时工作正常。但是当我在heroku上部署它时会抛出错误"图像的内容不是他们报告的内容"
发布模型
class Post < ActiveRecord::Base
belongs_to :topic
has_many :comments
has_many :ratings
belongs_to :user
#scope :recent, -> {where :user_id = 3)}
scope :t , ->(from) { where("posts.created_at > ?", from) }
scope :f , ->(from) { where("posts.created_at < ?", from) }
#scope :created_before, ->(time) { where("created_at < ?", time) }
has_and_belongs_to_many :users , join_table: :posts_users_read_status
has_and_belongs_to_many :tags
has_attached_file :image
validates_presence_of :name, :presence => true,message: "Name should not be blank"
validates_length_of :name,:maximum => 20,message: "Maximum 20 characters are allowed"
validates_attachment :image
validates_attachment_content_type :image, content_type: "image/jpeg"
validates_attachment_size :image, :in => 0..1024.kilobytes
do_not_validate_attachment_file_type :image
end
帖子的形式是
<%= form_for [@topic, @post],:html => {:class => "postsform",:multipart => true}, :remote => true do |f| %>
<% if @post.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this topic from being saved:</h2>
<ul>
<% @post.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="images">
<%= f.label :image %><br>
<%= f.file_field :image,class: "form-control" %>
</div>
<div class=namefield">
<%= f.label :Name %><br>
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :message %><br>
<%= f.text_area :message %>
</div>
<div class="Tags">
<%= f.label :Tags %><br>
<% @tags.each do |tag| %>
<div>
<%= check_box_tag "post[tag_ids][]", tag.id, @post.tags.include?(tag) %>
<%= tag.name %>
</div>
<% end %>
</div>
<%= link_to 'Create New Tags', tags_path %>
<div class="actions">
<div id="loading-indicator">
<%= image_tag("\assets\images\ajax-loading.gif", :id => "loading-indicator", :style => "display:none") %>
</div><%= f.button "Post", data: {disable_with:'<i class="fa fa-spinner fa-pulse"></i>Posting in'} ,id:"postb"%>
</div>
<% end %>
heroku日志
2016-01-06T04:33:01.991166+00:00 app[web.1]: [paperclip] Content Type Spoof: Filename images_(3).jpg (image/jpeg from Headers, [#<MIME::Type:0x007f63421e07d8 @content_type="image/jpe
g", @raw_media_type="image", @raw_sub_type="jpeg", @simplified="image/jpeg", @media_type="image", @sub_type="jpeg", @extensions=["jpeg", "jpg", "jpe"], @encoding="base64", @system=ni
l, @registered=true, @url=["IANA", "RFC2045", "RFC2046"], @obsolete=nil, @docs=nil>] from Extension), content type discovered from file command: . See documentation to allow this com
bination.