 <p>Just check to see if the ID passed to the controller methods is an integer.</p> <pre><code>if params[:id].is_a?(Integer) @user = User.find params[:id] else @user = User.find_by_login params[:id] </code></pre> <p>No need to add special routes.</p>