app/models/app_setting.rb
# Validates the current app setting based on its code.
Validates the current app setting based on its code.
Validates the current app setting based on its code .
def validate_all_app_settings
    if code == "allocation_precision"
      unless (value.to_f > 0) && (value.to_f % 1 == 0)
        errors.add(:value, "Not a positive integer")
      end
    elsif code == "fte_hours_per_week" 
      unless (value.to_f > 0) && (value.to_f <= 168)
        errors.add(:value, "Must be between 0 and 168")
      end
    elsif code == "logo" 
      unless value.blank? || value.index("http")
        errors.add(:value, "Must be a valid external URL")
      end
    elsif code == "filter_position" 
      unless value == "Left" || value == "Top"
        errors.add(:value, "Must be Left or Top")
      end
    end
  end
def validate_all_app_settings if code == "allocation_precision" unless ( value . to_f > 0 ) && ( value . to_f % 1 == 0 ) errors . add ( :value , "Not a positive integer" ) end elsif code == "fte_hours_per_week" unless ( value . to_f > 0 ) && ( value . to_f <= 168 ) errors . add ( :value , "Must be between 0 and 168" ) end elsif code == "logo" unless value . blank? || value . index ( "http" ) errors . add ( :value , "Must be a valid external URL" ) end elsif code == "filter_position" unless value == "Left" || value == "Top" errors . add ( :value , "Must be Left or Top" ) end end end
Validates the current app setting based on its code.
Validates the current app setting based on its code .