Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Exclude specific named routes #1246

nathanl opened this Issue Aug 5, 2011 · 2 comments


None yet
2 participants

nathanl commented Aug 5, 2011

I would like to be able to exclude specific routes (not controllers) from being generated.

For instance, we have an app where users should not be able to sign up (an existing user must create them), but should be able to edit their own passwords once they have an account.

This has come up before: http://groups.google.com/group/plataformatec-devise/browse_thread/thread/2e57d3bb14c1498f/c31a2647b102ff89?pli=1

I propose this syntax:

devise_for :users, :exclude_routes => %w[new_user_registration]

This would do nothing if a route by that name wasn't going to be created anyway.


  1. Would you like to have this feature?
  2. Do you like this syntax?

If so, I'd love to create a patch. I've already forked the project, but so far I'm having trouble understanding how the tests are set up. I haven't written route tests before, but I normally use Rspec and am accustomed to setting up conditions right before I test them. It looks to me like you set up a bunch of routes in test/rails_app/config/routes.rb and test them all in test/routes_test.rb. Is that correct?

I see where to go to modify devise_for. Any pointers on how to write the test first?



josevalim commented Aug 5, 2011

Today, you can skip the whole controller. It is not optimal in terms of usage, but setting up the routes for the whole controller manually is pretty straightfoward.

I believe that excluding routes by name is just going to make the routes generation code more complicated (than it already is) because we won't be able to use Rails helpers (like resource, resources and friends). In any case, thanks for forking the project and taking your time to suggest improvements.

And yes, we test routes exactly as you described.


@josevalim josevalim closed this Aug 5, 2011

nathanl commented Aug 5, 2011

Thanks for the quick and polite response. Hopefully I'll find some other way to contribute to Devise in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment