首页  >  问答  >  正文

ruby - 使用namespace时,form_tag的controller报错

我在routes.rb中建立了唯一一个namespace:

  namespace :help do
    root "qandas#index"
    resources :qandas
  end
  

同时也建立好了对应的Controller和view.

然后页面,报错:

ActionController::UrlGenerationError in Help::Qandas#index
No route matches {:action=>"index", :controller=>"help/search", :id=>nil}

报错的代码是:

= form_tag({:controller => 'search', :action => 'index', :id => @project}, :method => :get ) do
...

这就意味着,当我使用namespace的时候,会影响到以前通过{:controller => 'search', :action => 'index', :id => @project} 来定义的 url的地方。

有没有办法可以规避这一点?

黄舟黄舟2708 天前669

全部回复(1)我来回复

  • 巴扎黑

    巴扎黑2017-04-25 09:04:42

    我也遇到这个问题了。。。苦恼中,您现在解决了么

    回复
    0
  • 取消回复