On second thoughts I guess you need to update the `lastused` column ONLY when a person comes up in the search result as a manager on call for that day, since anyway the unavailable users are...
Attempting to find solutions from simple to advanced problems for which you have already found solutions in PHP and trying to replicate them using RoR would be one of my suggestions.
You can start by learning more about regexp from places like (http://www.tutorialspoint.com/php/php_regular_expression.htm) and then move on to online regexp testing websites like...
You could download open source asp.net scripts like http://www.nopcommerce.com/downloads.aspx , http://yetanotherforum.net/ etc and dissect it to your heart's content !