导轨:在路由文件中混合索引操作



我有以下路由设置。我需要使索引操作自动使用下面的PubMed_Search路由。

  resources :users do
    resources :publications do
       collection do
         get :pubmed_search
         post :pubmed_list
       end
     end
    end

我尝试了

  resources :users do
    resources :publications do
       collection do
         get 'publications', :action => :pubmed_search
         get :pubmed_search
         post :pubmed_list
       end
     end
    end

没有运气,我只能在控制器的索引方法中进行重定向,但是我相信有一种导轨可以做到这一点,我想学习。

编辑:

这有效

  get "/users/:user_id/publications" => "publications#pubmed_search", :as => "user_publications"

但是没有更好的方法,使用RESTFUL资源?

这有效

get"/user/:user_id/publications" =>"出版物#pubmed_search",:as => =>" user_publications"

最新更新