improved basename detection; checks if is a valid rails app