Q:

Make a field optional in rails

I use paperclip to attach an avatar to users, which works fine but when a new user attempts to register it complains about the avatar bieng too small and not of the right type.
This is how i validate my avatars:
validates_attachment_size :avatar, :less_than => 1.megabytes
validates_attachment_content_type :avatar, :content_type => ['image/jpeg', 'image/png', 'image/gif']

This is the error i get when i try to register.
There were problems with the following fields:

* Avatar file size file size must be between 0 and 1048576 bytes.
* Avatar content type is not included in the list

is there anyway to make it so that avatar can be blank?

A:

I don't know if this is gonna work but try:
validates_attachment_size :avatar, :less_than => 1.megabytes, :if => avatar_changed?
validates_attachment_content_type :avatar, :content_type => ['image/jpeg', 'image/png', 'image/gif'], :if => avatar_changed?

