> For the complete documentation index, see [llms.txt](https://ploegert.gitbook.io/til/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ploegert.gitbook.io/til/programmy/rails/customize-paths-and-helpers-for-devise-routes.md).

# Customize Paths And Helpers For Devise Routes

Wih a default Devise setup (`devise_for :users`), the sign up/in/out routes are located at `/users/sign_up`, `/users/sign_in`, and `/users/sign_out`. And the path helpers are `new_user_registration_path`, `new_user_session_path`, and `destroy_user_session_path`, respectively.

These can be customized in `config/routes.rb` by opening up the `devise_scope :user` block and re-specifying the routes of interest.

```ruby
Rails.application.routes.draw do
  devise_for :users
  devise_scope :user do
    get 'sign_up', to: 'devise/registrations#new'
    get 'sign_in', to: 'devise/sessions#new'
    delete 'sign_out', to: 'devise/sessions#destroy'
  end
end
```

These three custom routes override the paths and helps I described above like so:

* `sign_up_path` -> `/sign_up`
* `sign_in_path` -> `/sign_in`
* `sign_out_path` -> `/sign_out`

I find these path helpers easier to work with and I like the UX of registration/session paths not nested under `/user`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ploegert.gitbook.io/til/programmy/rails/customize-paths-and-helpers-for-devise-routes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
