I am using carrierwave to upload the profile picture in user model. If the user tries to upload any file that is not an image, then an error must be raised. However the error is displayed twice on the screen. Please help
code for user model class User < ActiveRecord::Base
include CarrierWave::MiniMagick
validates :email, :presence =>true, :uniqueness => {case_sensitive: false}, :format => { :with=> /([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)/, :message => "please enter a valid e-mail" }
validates :name, :presence=>true
validates :password ,:presence =>true, :confirmation=> true #, :length =>{ :minimum=>6, :maximum=>30}, :format=>{:with=>/(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,30}/}
#for the image
mount_uploader :image, ImageUploader
#for the password
has_secure_password
end
**code ImageUploader **
def scale(width, height)
image.resize widthxheight
end
#Create different versions of your uploaded files:
version :thumb do
process :resize_to_fit => [50, 50]
end
# Add a white list of extensions which are allowed to be uploaded.
def extension_white_list
%w(jpg jpeg gif png)
end
code for error partials
<% if object.errors.any?%>
<ul>
<%= object.errors.full_messages.each do |message|%>
<li><%= message%></li>
<%end%>
</ul>
<%end%>