更改Active_Admin资源的URL |如何iverwrite AA路由?

时间:2011-11-20 12:49:32

标签: ruby-on-rails activeadmin

我想将资源的路径从“/ partner_programms”更改为“/ programmangebot”。

有没有办法用active_admin来实现它而不用我自己的路由到routes.rb?

ActiveAdmin do:

       admin_categories GET        /admin/categories(.:format)                {:action=>"index", :controller=>"admin/categories"}
                    POST       /admin/categories(.:format)                {:action=>"create", :controller=>"admin/categories"}
 new_admin_category GET        /admin/categories/new(.:format)            {:action=>"new", :controller=>"admin/categories"}
edit_admin_category GET        /admin/categories/:id/edit(.:format)       {:action=>"edit", :controller=>"admin/categories"}
     admin_category GET        /admin/categories/:id(.:format)            {:action=>"show", :controller=>"admin/categories"}
                    PUT        /admin/categories/:id(.:format)            {:action=>"update", :controller=>"admin/categories"}
                    DELETE     /admin/categories/:id(.:format)            {:action=>"destroy", :controller=>"admin/categories"}

当我做的时候

#routes.rb
namespace :admin do
  resources :categories, :path=>"Kategorien"
end

我得到未命名的路线

               admin_categories GET        /admin/categories(.:format)                {:action=>"index", :controller=>"admin/categories"}
                            POST       /admin/categories(.:format)                {:action=>"create", :controller=>"admin/categories"}
         new_admin_category GET        /admin/categories/new(.:format)            {:action=>"new", :controller=>"admin/categories"}
        edit_admin_category GET        /admin/categories/:id/edit(.:format)       {:action=>"edit", :controller=>"admin/categories"}
             admin_category GET        /admin/categories/:id(.:format)            {:action=>"show", :controller=>"admin/categories"}
                            PUT        /admin/categories/:id(.:format)            {:action=>"update", :controller=>"admin/categories"}
                            DELETE     /admin/categories/:id(.:format)            {:action=>"destroy", :controller=>"admin/categories"}
                            GET        /admin/Kategorien(.:format)                {:action=>"index", :controller=>"admin/categories"}
                            POST       /admin/Kategorien(.:format)                {:action=>"create", :controller=>"admin/categories"}
                            GET        /admin/Kategorien/new(.:format)            {:action=>"new", :controller=>"admin/categories"}
                            GET        /admin/Kategorien/:id/edit(.:format)       {:action=>"edit", :controller=>"admin/categories"}
                            GET        /admin/Kategorien/:id(.:format)            {:action=>"show", :controller=>"admin/categories"}
                            PUT        /admin/Kategorien/:id(.:format)            {:action=>"update", :controller=>"admin/categories"}
                            DELETE     /admin/Kategorien/:id(.:format)            {:action=>"destroy", :controller=>"admin/categories"}

2 个答案:

答案 0 :(得分:5)

另一种方法是重命名资源:

ActiveAdmin.register Partner::Programms, as: 'Programmangebot' do

这会更改对资源的所有引用。

答案 1 :(得分:-1)

您可以按照Rails Best Practices – split route namespaces into different files中的说明通过其他文件添加路线。我不知道你是如何删除现有路线的。

正确回答评论:

尝试在ActiveAdmin.routes(self)之后添加admin / Kategorien并获得与您相同的结果,新路由未命名。如果我将admin / Kategorien路由放在ActiveAdmin.routes(self)之上,那么我的Kategorien路由被命名,而ActiveAdmin路由未命名。