回形针尺寸验证错误消息显示两次

时间:2014-11-18 07:10:39

标签: ruby-on-rails-4 ruby-on-rails-3.2 paperclip paperclip-validation

在redemption_image.rb中,

class RedemptionImage < ActiveRecord::Base
  belongs_to :business, :touch => true

  has_attached_file :display_image, :url => "/system/:class/:attachment/:id_partition/:hash.:extension",
                               :hash_secret => "redemptionimagesqqqa"
  validates_attachment :display_image, :content_type => { :content_type => /\Aimage/ }, :size => { :in => 0..300.kilobytes,
:message => "must be lesser than 300 KB. Image height and width must be lesser than 500 px." }

对display_image的size,content_type和presence进行验证。 它显示消息两次:保存兑换图像时出错:显示图像文件大小必须小于300 KB。图像高度和宽度必须小于500像素。显示图像必须小于300 KB。图像高度和宽度必须小于500像素。

如果未提供自定义消息,则会闪烁两次错误,如图所示 enter image description here

0 个答案:

没有答案