require 'constraints/group_url_constrainer' constraints(GroupUrlConstrainer.new) do scope(path: ':id', as: :group, constraints: { id: /[a-zA-Z.0-9_\-]+(? 'groups#show', as: :group_canonical end