Skip to content

Latest commit

 

History

History
15 lines (12 loc) · 275 Bytes

rails_active_model.md

File metadata and controls

15 lines (12 loc) · 275 Bytes

validation & custom validators

simple one function solution

class User < ActiveRecord::Base
  validate :check_photo_dimensions

  def check_photo_dimensions
    if photo_width < 480
      errors.add :photo, "Width of photo is too small." 
    end
  end
end