# RESTful routes not letting me rest

**URL:** <https://www.ruby-forum.com/t/restful-routes-not-letting-me-rest/125951>\
**Category:** Rails\
**Created:** [January 14, 2008, 5:20am UTC](https://www.ruby-forum.com/t/restful-routes-not-letting-me-rest/125951 "2008-01-14T05:20:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [January 14, 2008, 5:20am UTC](https://www.ruby-forum.com/t/restful-routes-not-letting-me-rest/125951/1 "2008-01-14T05:20:01Z")

</div>

Okay, so in my users controller I have defined a modify function. And  
then in my views I have placed my modify view. Then in my routes I  
have added:

map.resources :users, :collection =\> {:login =\> :get, :logout  
=\> :get, :modify =\> :get }

But this doesn’t work:

\<%= link\_to ‘Update Information’, modify\_user\_path %\>

And I have no idea why modify\_user\_path doesn’t work. It also doesn’t  
work for the login and logout that I had to define in my routes.rb.  
So, 1)why doesn’t the restful-ness work? and 2) Why do i have to  
modify my routes.rb anyway? Shouldn’t things by automatic when I  
create a new function? It always assumes that something like

/users/newfunction is supposed to be routed to /users/show and [:id] =  
newfunction.

By the way, I’m using Rails 1.2.6. Thanks for any help!!

-Ryan

---

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [January 14, 2008, 5:38am UTC](https://www.ruby-forum.com/t/restful-routes-not-letting-me-rest/125951/2 "2008-01-14T05:38:43Z")

</div>

Because you’re defining it on a COLLECTION of that resource rather than  
a  
MEMBER of that resource 🙂

it should be: map.resources :users, :collection =\> { :login =\> :get,  
:logout  
=\> :get }, :member =\> { :modify =\> :get }

Perhaps look at using restful\_authentication.

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [January 14, 2008, 7:23am UTC](https://www.ruby-forum.com/t/restful-routes-not-letting-me-rest/125951/3 "2008-01-14T07:23:53Z")

</div>

Still can’t rest. You see, I don’t plan to go to

/users/1/modify

I need to get to

/users/modify

So wouldn’t that make it part of collection? I’ve already tried it  
both ways anyway, and “modify\_user\_path” still doesn’t work. I think I  
even tried “modify\_users\_path”… but there’s another question, which  
one should I be using in which circumstance? I’m guessing you use  
“\_users\_path” for collection (ie do something to many users) versus  
“\_user\_path” for member (ie do something to just one user?) The  
specific user\_id to modify is already saved in the session. The modify  
just checks that the user\_id is there and then calls the modify view  
to modify that user id. (I’m using modify instead of just plain ol  
‘edit’ because edit is going to edit different object attributes.

---

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [January 14, 2008, 11:57am UTC](https://www.ruby-forum.com/t/restful-routes-not-letting-me-rest/125951/4 "2008-01-14T11:57:04Z")

</div>

kopf1988 wrote:

> Still can’t rest. You see, I don’t plan to go to
> 
> /users/1/modify
> 
> I need to get to
> 
> /users/modify

Perhaps you should revisit the overall design of your application.

What are you “modifying” about your collection of users?

Without knowing anything about your problem domain I would suggest  
something like /group/edit to remain within the Rails conventions.

Just a thought…

---

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [January 14, 2008, 5:41pm UTC](https://www.ruby-forum.com/t/restful-routes-not-letting-me-rest/125951/5 "2008-01-14T17:41:42Z")

</div>

I am only modifying one user, but I don’t want to have to use that  
type of url - I want to go to /users/modify. That’s because modify is  
a protected page and if they are not logged in they are sent back to  
the login page, otherwise they are allowed to modify themself. Like an  
“update your personal information here” page.

On Jan 14, 4:57 am, Daniel W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
