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, controller: :users) do get '/', action: :show end end scope(path: 'u/:username', as: :user, constraints: { username: /[a-zA-Z.0-9_\-]+(?