- has_attached_file :image,
- :default_url => "/assets/:class/:attachment/:style.png",
- :styles => { :large => "100x100>", :small => "50x50>" }
-
- validates_presence_of :email, :display_name
- validates_confirmation_of :email # , :message => ' addresses must match'
- validates_confirmation_of :pass_crypt # , :message => ' must match the confirmation password'
- validates_uniqueness_of :display_name, :allow_nil => true, :case_sensitive => false, :if => proc { |u| u.display_name_changed? }
- validates_uniqueness_of :email, :case_sensitive => false, :if => proc { |u| u.email_changed? }
- validates_uniqueness_of :openid_url, :allow_nil => true
- validates_length_of :pass_crypt, :within => 8..255
- validates_length_of :display_name, :within => 3..255, :allow_nil => true
+ has_one_attached :avatar, :service => Settings.avatar_storage
+
+ validates :display_name, :presence => true, :length => 3..255,
+ :exclusion => %w[new terms save confirm confirm-email go_public reset-password forgot-password suspended]
+ validates :display_name, :if => proc { |u| u.display_name_changed? },
+ :uniqueness => { :case_sensitive => false }
+ validates :display_name, :if => proc { |u| u.display_name_changed? },
+ :characters => { :url_safe => true },
+ :whitespace => { :leading => false, :trailing => false }
+ validates :email, :presence => true, :confirmation => true, :characters => true
+ validates :email, :if => proc { |u| u.email_changed? },
+ :uniqueness => { :case_sensitive => false }
+ validates :email, :if => proc { |u| u.email_changed? },
+ :whitespace => { :leading => false, :trailing => false }
+ validates :pass_crypt, :confirmation => true, :length => 8..255
+ validates :home_lat, :allow_nil => true, :numericality => true, :inclusion => { :in => -90..90 }
+ validates :home_lon, :allow_nil => true, :numericality => true, :inclusion => { :in => -180..180 }
+ validates :home_zoom, :allow_nil => true, :numericality => { :only_integer => true }
+ validates :preferred_editor, :inclusion => Editors::ALL_EDITORS, :allow_nil => true
+ validates :auth_uid, :unless => proc { |u| u.auth_provider.nil? },
+ :uniqueness => { :scope => :auth_provider }
+ validates :avatar, :if => proc { |u| u.attachment_changes["avatar"] },
+ :image => true
+