diff options
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 1b0c82f45c4..37285c2a9d4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -99,9 +99,7 @@ class User < ActiveRecord::Base attr_accessor :login # Virtual attributes to define avatar cropping - [:avatar_crop_x, :avatar_crop_y, :avatar_crop_size].each do |field| - attr_accessor field - end + attr_accessor :avatar_crop_x, :avatar_crop_y, :avatar_crop_size # # Relations @@ -169,7 +167,7 @@ class User < ActiveRecord::Base validates :avatar, file_size: { maximum: 200.kilobytes.to_i } [:avatar_crop_x, :avatar_crop_y, :avatar_crop_size].each do |field| - validates field, numericality: { only_integer: true }, allow_blank: true + validates field, numericality: { only_integer: true }, presence: true, if: ->(user) { user.avatar_changed? } end before_validation :generate_password, on: :create |