RESTful routes not letting me rest

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

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

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

Perhaps look at using restful_authentication.

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.

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...

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.