2013-05-02 150 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

相关问题