2013-05-02 136 views
1

我有一個搜索控制器(無模型),我正在對Users表運行查詢。它的工作原理完全沒問題,但一旦我進入這個Rails:ActionController :: RoutingError沒有路由匹配錯誤

<%= link_to "Good to proceed now.", new_user_product_path, :class => "btn" %> 

它給我的用戶和產品模型之間estbalished

ActionController::RoutingError (No route matches {:action=>"new", :controller=>"products"}): 

我已經有關係。當我直接轉到鏈接http://127.0.0.1:3000/users/3/products/new時,我可以訪問products#new。但是,再次,當link_to片段被輸入時,它會給出上述錯誤。

我的搜索是控制器未綁定數據庫,它只是幫助我處理前端。

我在這裏做錯了什麼?有什麼我需要做的路線?

這裏是我的路線文件

resources :searches, only: [:index, :create] 
    resources :users do 
     resources :products 
    end 

回答

1

您需要的用戶傳遞到new_user_product_path

因此,像:

new_user_product_path(@user)new_user_product_path(current_user)

+0

我幾乎sweared。不相信是這樣的,哈哈。非常感謝 :) – psharma 2013-05-02 17:16:41

相關問題