Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6252885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:53:15+00:00 2026-05-24T13:53:15+00:00

devise_for creates routes including a DELETE route, which we want to remove, and devise_for

  • 0

devise_for creates routes including a DELETE route, which we want to remove, and devise_for doesn’t support an :except or :only option.

How can I remove a route from Rails.application.routes? Either in the draw block, or afterward?


Here are details of a bug, which was the reason we needed to remove the route.

  • we were issuing a DELETE request to a custom UJS controller action

  • in the controller action we were removing what we wanted to, then doing a 302 redirect. This was a bad idea, and we have since corrected it by returning some JSON instead.

  • some clients, upon receiving the 302 would issue a new DELETE request to the redirect, which routes to a Devise delete route! Thereby inadvertantly deleting the person! Yikes. We were assuming this would be a GET. Bad assumption.

This bug has been fixed, but i would like to remove the route nonetheless.


Here is what I did in the end, which was suggested by the bounty-winner in his quote from Jose´ Valim:

In config/routes.rb, I added this above the devise_for call, which sets up the rest of my 'people' routes:

delete '/person', :to => 'people#destroy'

Then in my existing people_controller.rb, I added a no-op method:

def destroy
  render :nothing => true
end

I’m still a little irked that there isn’t a simple way to just remove the route from the RouteSet. Also, the delete route still exists for the devise controller, but it won’t get called because rails looks for the first match in config/routes.rb and returns it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:53:16+00:00Added an answer on May 24, 2026 at 1:53 pm

    Here is what Jose Valim (the author of devise) has to say on the subject:

    There is no way to remove routes individually. Or you use :skip to
    remove all and draw the ones you need manually or you overwrite this
    routes by defining a route to the same path first in your config/
    routes.rb

    So the short answer to your question is no, you can’t delete that one route. You can of course try doing things like patching the devise_for method, but that would be a somewhat involved undertaking (a day or several worth of effort). I’d just use the :skip option, then implement the routes you do want for that controller and leave off the one that you don’t.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

destroy_user_session doesn't appear in my routes although routes.rb is configured # routes.rb # devise_for
Can i create custom touch events for iPhone?? will the device support for creating
I want to add the option to register with a JSON format and some
I'm trying to make a two-step confirmation like heroku using Devise. My routes: devise_for
routes.rb => devise_for :users resources :posts match posts/:id/categ => posts#categ match posts/:id/tag_posts => posts#tag_posts
routes.rb => Sendemail::Application.routes.draw do devise_for :users get user/index get home/index root :to => 'home#index'
On core website I use standard Devise configuration for user authentication. In routes.rb: devise_for
I have the following routes in my 3.1.0.rc5 app # config/routes.rb devise_for :users resources
I have this in routes.rb root :to => posts#index devise_for :users, :controllers => {
I am using embedded-linux for device which has Arch ARMv5 Speed 266MHZ, vfpu and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.