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

发布于 2024-10-31 21:15:00 字数 2406 浏览 1 评论 0原文

间隙定义了以下路线: routes.rb

但我想指定我自己的路线:

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

' rake 路线'给出:

            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)

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", :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"}

How can i remove the default routes generated by Clearance?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

七七 2024-11-07 21:15:00

看起来像(来自这篇文章:http:// robots.thoughtbot.com/post/159805560/tips-for-writing-your-own-rails-engine)创建者煞费苦心地确保应用程序的路线覆盖通关路线。 (您可以将它们全部发送到未找到的页面或定义您自己的操作。)

但我知道没有办法简单地取消定义它们。

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.

遇见了你 2024-11-07 21:15:00

我通过出售宝石解决了这个问题。如中所述: 如何为 Rails3 供应 gems/ 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 中删除了我不需要的路由
这不是最干净的解决方案,但它确实有效!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文