In my model, I have:
validates_presence_of :start_date, :message => 'Please enter date.'
validate :start_date_exist_check , on: :create`
def start_date_exist_check
@check_date = Employee.where('start_date = ?', start_date)`
if @check_date.blank?
end
end
validate_presence_of
is executed after my module start_date_exist_check
, which creates a problem.
Can anybody tell me how I can validate the field first?