开发者

How can i remove the default routes generated by Clearance?

Clearance defines the following routes: routes.rb

But I want to specify my own routes:

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

'rake routes' gives:

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

but also (i don't want these):

          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", :control开发者_JS百科ler=>"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"}

How can i remove the default routes generated by Clearance?

clearance (0.10.3.2), rails (3.0.6), ruby (1.9.2p180)


Looks like (from this post: http://robots.thoughtbot.com/post/159805560/tips-for-writing-your-own-rails-engine) the creators took great pains to ensure that the app's routes override clearance's routes. (You could send them all to a page not found or define your own action. )

I know of no way to to simply undefine them though.


I solved it by vendoring the gem. Like described in: How do I vendorize gems for Rails3/Bundler

First did:

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

Then added the path in my Gemfile:

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

Then I removed the routes I didn't want in vendor/gems/clearance-0.10.3.2/config/routes.rb It's not the most clean solution, but it works!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜