如何在 rails 5 中路由到具有可变值的特定控制器?

How to routes to a specific controller with a variable value ahead of it in rails 5?

通常是这样的: 资源:用户 为了保持领先的价值,我们可以像

scope :url do
   resources :users
end

但是,问题是我在路由前面的 just 变量不是一个固定值,几乎没有条件。 rails 2. 中的示例,并希望将路由编码转换为 rails5

map.with_options :controller => 'users' do |user|
  user.forgot_user ':url/users/forgot',   :action => 'forgot',  :url => /([a-zA-Z0-9\-]*)/
  user.user ':url/users/retrieve',   :action => 'retrieve',  :url => /([a-zA-Z0-9\-]*)/
  user.login       ':url/users/login',    :action => 'login',                                          :url => /([a-zA-Z0-9\-]*)/
  user.logout      ':url/users/logout',   :action => 'logout',                                         :url => /([a-zA-Z0-9\-]*)/
  user.new_user    ':url/users/new',      :action => 'new',     :conditions => { :method => :get },    :url => /([a-zA-Z0-9\-]*)/
  user.users       ':url/users/:id',      :action => 'show',   :conditions => { :method => :get },    :url => /([a-zA-Z0-9\-]*)/
end

提前致谢。

scope "/(:subdomain)", :defaults => {:subdomain => "default"} do
  ...
end

使用子域作为变量。