如何删除 Clearance 生成的默认路由?
间隙定义了以下路线: 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来像(来自这篇文章: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.
我通过出售宝石解决了这个问题。如中所述: 如何为 Rails3 供应 gems/ Bundler
首先:
然后在我的 Gemfile 中添加路径:
然后我在
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:
Then added the path in my Gemfile:
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!