finally got the search to work for rails function