简体   繁体   English

Rails 3中的平稳路线问题

[英]Problem with restful route in Rails 3

I have the following in routes.rb: 我在routes.rb中具有以下内容:

  resource :account, :controller => "accounts"
  resources :accounts

this redirect is in a controller: 此重定向在控制器中:

  redirect_to account_url

and when this redirect is called, I get the following error: 当调用此重定向时,出现以下错误:

Routing Error 路由错误

No route matches {:action=>"destroy", :controller=>"accounts"} 没有路由匹配{:action =>“ destroy”,:controller =>“ accounts”}

The following are displayed when running rake routes : 运行耙线时显示以下内容:

... ...
... ...
accounts DELETE /accounts(.:format) {:action=>"destroy", :controller=>"accounts"} 帐户DELETE /accounts(.:format){:action =>“ destroy”,:controller =>“ accounts”}
... ...
... ...
account DELETE /accounts/:id(.:format) {:action=>"destroy", :controller=>"accounts"} 帐户DELETE /accounts/:id(.:format){:action =>“ destroy”,:controller =>“ accounts”}
... ...
... ...

So it seems to me that I've got the {:action=>"destroy", :controller=>"accounts"} covered -> according to rake routes anyways. 因此,在我看来,{> action =>“ destroy”,:controller =>“ accounts”}的覆盖范围->都是根据耙路确定的 Anyone have an idea as to what I'm doing wrong? 有人知道我在做什么错吗?

What's that first route's intention? 那第一条路线的意图是什么? It should be enough with the second one to map HTTP verbs to controller actions automatically. 第二个足以将HTTP动词自动映射到控制器动作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM