2010-01-29 48 views
0

我有一个Store模型。而且两个控制器:为解决“错误”url的相同资源使用不同控制器的稳定路由

  • stores_controller
  • 管理/ stores_controller
现在

在admin/stores_controller我试图生成在管理/ stores_controller纽带,以破坏行动的列表视图,但我试过的每一个变种都会去stores_controller(所以不是管理员)或其他一些不正确的网址。

我currenty使用

<%= link_to "Delete", :controller => "admin/stores", 
      :action => "destroy", :id => store, :method => :delete %> 

但这产生像http://localhost:3000/admin/stores/5?method=delete一个URL其调用show动作,而不是摧毁一个。

在routes.rb中我有

map.namespace :admin do |admin| 
    admin.resources :stores 
end 

map.resources :stores 

我该如何解决这个问题?

回答

1

当你有一个命名空间,使用link_to像这样:

link_to 'Show', [:admin, @var] 

同样,如果你想引用一个形式:

form_for([:admin, @var]) 

相关问题