what default value of a date should be given that it returns all the record if user has not entered date in squeel

I am using a squeel gem and I have a scenario that when user does not enter employee joining date then all the records should be returned else return record on the basis of employees joining date. my query is loke this :

date = Date.today Employee.joins { passports.visas }.where { (employees.joining_date.eq "%#{date}%")

so if date is not given by the user then what should I put the default value of date so that it retrieve all the record?

Answers


simply make call back

in Employee model before_create :joining_date

def joining_date self.joining_date = Date.today end


Need Your Help

Use jQuery trigger() with hoverIntent

javascript jquery hoverintent

Is it possible to trigger a hoverIntent on an element.

Pointer object not being declared in scope

c++ pointers hashtable declaration

This is driving me crazy. In the search function definition, Dev c++ is saying that