This is my model file.
class Attendance < ActiveRecord::Base
belongs_to :staff, class_name: 'User', foreign_key: 'staff_id', inverse_of: :attendances
belongs_to :child, inverse_of: :attendances
validates :attendance_date, uniqueness: {scope: :child}
end
my main goal is to not allow the same date and child_id to be saved in database.The validation which i wrote is not working in this scenario.
The attendance_date is a datetime field.
please help me solve this issue!!