require 'constraints/user_url_constrainer' get '/u/:username', to: redirect('/%{username}'), constraints: { username: /[a-zA-Z.0-9_\-]+(? 'omniauth_callbacks#omniauth_error', as: :omniauth_error get '/users/almost_there' => 'confirmations#almost_there' end constraints(UserUrlConstrainer.new) do scope(path: ':username', as: :user, constraints: { username: /[a-zA-Z.0-9_\-]+(?