Replaced inefficient db search using <class>.all.each with the <class>.where and <class>.joins().where(); also re-added the code for the default text and focus change for some of the search fields