Forums » Development »
Validations (custom fields) on time entry
Added by RENZO MEJIA REYES over 8 years ago
Help, I am starting on ruby, I want any validations with custom fields and values on model time entry
My code:
def validate_time_entry
errors.add :custom_field_values, :invalid if custom_field_values == 'Normal'
errors.add :hours, :invalid if hours && (hours < 0 || hours >= 1000)
errors.add :project_id, :invalid if project.nil?
errors.add :issue_id, :invalid if (issue_id && !issue) || (issue && project!=issue.project) || @invalid_issue_id
errors.add :activity_id, :inclusion if activity_id_changed? && project && !project.activities.include?(activity)
end
Doesn´t work
Sorry for my english, thanks