search

Home  >  Q&A  >  body text

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的地方。

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

黄舟黄舟2774 days ago727

reply all(1)I'll reply

  • 巴扎黑

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

    I also encountered this problem. . . In distress, have you solved it now?

    reply
    0
  • Cancelreply