# Devise Nested Resources

**URL:** <https://www.ruby-forum.com/t/devise-nested-resources/193340>\
**Category:** Rails\
**Created:** [August 16, 2010, 8:13am UTC](https://www.ruby-forum.com/t/devise-nested-resources/193340 "2010-08-16T08:13:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/da6949/32.png) [@dfx](https://www.ruby-forum.com/u/dfx)\
**Post date:** [August 16, 2010, 8:13am UTC](https://www.ruby-forum.com/t/devise-nested-resources/193340/1 "2010-08-16T08:13:39Z")

</div>

I’m working on a new Rails (v3.0.0.rc) application using the Devise  
(v1.1.1) gem. In my application I have setup a User model which  
includes the person’s e-mail address and name. I have also setup the  
following models that I’d like to attach to the User:

- Address (street, city, state, zip code)
- Interest (name)
- Donation (date of donation, amount)

My question is how can I go about setting up routing for these nested  
resources? When reading the documentation for Rails 3 routing I saw  
the that the following was possible:

resources :users do  
resource :address  
resources :interests, :donations  
end

Although when using devise, the `devise_for :users` helper doesn’t  
appear to accept a block of nested resources. Does anyone have any  
ideas on what I can do to setup this behavior (or propose alternative  
ideas on what I could do). Any help would be greatly appreciated,  
thanks!

---

<div class="post-metadata">

**Author:** ![dfx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/da6949/32.png) [@dfx](https://www.ruby-forum.com/u/dfx)\
**Post date:** [August 28, 2010, 3:17am UTC](https://www.ruby-forum.com/t/devise-nested-resources/193340/2 "2010-08-28T03:17:02Z")

</div>

I just happened to be looking for the same information. I found it  
here:

[http://www.michaelharrison.ws/weblog/?p=349](http://www.michaelharrison.ws/weblog/?p=349)

To quote the relevant part:

The solution is to give devise\_for an alternate path to use for user  
authentication, e.g. accounts:

devise\_for :users, :path =\> ‘accounts’

resources :users do  
resources :someresources  
end

It doesnâ€™t matter what path you use, since devise is going to use its  
own controller to handle authentication requests.

---

<div class="post-metadata">

**Author:** ![dfx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/da6949/32.png) [@dfx](https://www.ruby-forum.com/u/dfx)\
**Post date:** [August 29, 2010, 12:35am UTC](https://www.ruby-forum.com/t/devise-nested-resources/193340/3 "2010-08-29T00:35:01Z")

</div>

Thanks, this is just what I was looking for.
