rails 关注的自定义路径

rails custom path on concerns

所以这里有我的路线

concern :search do
  scope '/search' do
    get '/', to: 'users#search'
    get '/schedule/:id', to: 'schedules#user'
  end
end

concerns :search

scope '/dashboard' do  
  concerns :search
end

问题是 rails 没有给我路径助手。我怎么能根据我称之为的地方有不同的路径来解决我的问题。我想要这样的东西

search_path
search_schedule_path

dashboard_search_path
dashboard_search_schedule_path

终于想通了

concern :search do
  scope '/search', as: :search do
    get '/', to: 'users#search'
    get '/schedule/:id', to: 'schedules#user', as: :schedule
  end
end

concerns :search

scope '/dashboard', as: :dashboard do  
  concerns :search
end

这是我的路径助手

search_path
search_schedule_path

dashboard_search_path
dashboard_search_schedule_path