如何删除Clearance生成的默认路由?

时间:2011-04-13 13:57:32

标签: ruby-on-rails ruby-on-rails-3 routes clearance

Clearance定义了以下路线: routes.rb

但我想指定自己的路线:

match 'login'  => 'clearance/sessions#new', :as => 'sign_in'
match 'logout' => 'clearance/sessions#destroy', :via => :delete, :as => 'sign_out'

'rake routes'给出:

            sign_in        /login(.:format)                        {:action=>"new", :controller=>"clearance/sessions"}
           sign_out DELETE /logout(.:format)                       {:action=>"destroy", :controller=>"clearance/sessions"}

但也(我不想要这些):

          passwords POST   /passwords(.:format)                    {:action=>"create", :controller=>"clearance/passwords"}
       new_password GET    /passwords/new(.:format)                {:action=>"new", :controller=>"clearance/passwords"}
            session POST   /session(.:format)                      {:action=>"create", :controller=>"clearance/sessions"}
        new_session GET    /session/new(.:format)                  {:action=>"new", :controller=>"clearance/sessions"}
                    DELETE /session(.:format)                      {:action=>"destroy", :controller=>"clearance/sessions"}
      user_password POST   /users/:user_id/password(.:format)      {:action=>"create", :controller=>"clearance/passwords"}
 edit_user_password GET    /users/:user_id/password/edit(.:format) {:action=>"edit", :controller=>"clearance/passwords"}
                    PUT    /users/:user_id/password(.:format)      {:action=>"update", :controller=>"clearance/passwords"}
              users POST   /users(.:format)                        {:action=>"create", :controller=>"clearance/users"}
           new_user GET    /users/new(.:format)                    {:action=>"new", :controller=>"clearance/users"}
            sign_up        /sign_up(.:format)                      {:action=>"new", :controller=>"clearance/users"}
            sign_in        /sign_in(.:format)                      {:action=>"new", :controller=>"clearance/sessions"}
           sign_out DELETE /sign_out(.:format)                     {:action=>"destroy", :controller=>"clearance/sessions"}

如何删除Clearance生成的默认路由?

间隙(0.10.3.2),轨道(3.0.6),红宝石(1.9.2p180)

2 个答案:

答案 0 :(得分:2)

看起来(来自这篇文章:http://robots.thoughtbot.com/post/159805560/tips-for-writing-your-own-rails-engine)创作者花了很大力气确保应用程序的路线覆盖清除路线。 (您可以将它们全部发送到未找到的页面或定义您自己的操作。)

我知道无法简单地取消定义它们。

答案 1 :(得分:2)

我通过销售宝石解决了这个问题。如:How do I vendorize gems for Rails3/Bundler

中所述

首先做了:

gem unpack clearance --version 0.10.3.2 --target vendor/gems

然后在我的Gemfile中添加了路径:

gem 'clearance', :path => "vendor/gems/clearance-0.10.3.2"

然后我删除了vendor/gems/clearance-0.10.3.2/config/routes.rb中我不想要的路线 它不是最干净的解决方案,但它有效!