Ruby on rails 如何覆盖:自定义管线的路径名称

Ruby on rails 如何覆盖:自定义管线的路径名称,ruby-on-rails,ruby-on-rails-3,routes,Ruby On Rails,Ruby On Rails 3,Routes,我已经用英语实现了RESTFUL路由,但该应用程序是为德国用户提供的,因此路由应该重命名为德语。我使用:path_names选项和CRUD路由实现了这一点,但这不适用于我自己创建的路由。例如,模型SingleBudget有一个从n..n关联中删除特定对象的操作。在myroutes.rb中,它看起来像这样: resources :single_budgets, :path => 'einzelbudgets', :path_names => { :new => 'neu', :e

我已经用英语实现了RESTFUL路由,但该应用程序是为德国用户提供的,因此路由应该重命名为德语。我使用:path_names选项和CRUD路由实现了这一点,但这不适用于我自己创建的路由。例如,模型
SingleBudget
有一个从n..n关联中删除特定对象的操作。在my
routes.rb中,它看起来像这样:

resources :single_budgets, :path => 'einzelbudgets', :path_names => { :new => 'neu', :edit => 'aendern', :remove => 'entfernen' } do
     collection do
          get ':id/remove' => "single_budgets#remove", :as => :remove
     end
end

它适用于新建和编辑操作,但不适用于删除操作。有人知道如何修复它吗?

参数
:path\u names
只会影响内置CRUD操作。对于自定义操作,只需在
get
参数中调用它即可:

get ':id/entfernen' => "single_budgets#remove", :as => :remove
这将为您提供一个
remove\u single\u budgets
路径,该路径将指向
/single\u budgets/:id/entfernen
,该路径将在控制器中执行
remove
方法