Currently the attachments are searched based on attachment_file_name
, tags
and employee_id
, I would like to search based on Employee name as well, how can I go with it?
Two models must be used.
- Employee - which has name of employee
- LessonplanAttachment - contains the id of the employee.
The code part.
def search_ajax
@attachments = LessonplanAttachment.find(:all,
:conditions => ["attachment_file_name LIKE ? OR tags LIKE ? OR employee_id = ?",
"#{params[:query]}%","#{params[:query]}%",params[:query]])
end