fix routing issue

Most of the code in this block is the same as in ```Rails23#recognizes?```. Refactor to reuse this common code.