# RESTful rails customized resource mapping concerning edit action and monolithic template

**URL:** <https://www.ruby-forum.com/t/restful-rails-customized-resource-mapping-concerning-edit-action-and-monolithic-template/120348>\
**Category:** Rails\
**Created:** [November 16, 2007, 12:32am UTC](https://www.ruby-forum.com/t/restful-rails-customized-resource-mapping-concerning-edit-action-and-monolithic-template/120348 "2007-11-16T00:32:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ptontiger](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@ptontiger](https://www.ruby-forum.com/u/ptontiger)\
**Post date:** [November 16, 2007, 12:32am UTC](https://www.ruby-forum.com/t/restful-rails-customized-resource-mapping-concerning-edit-action-and-monolithic-template/120348/1 "2007-11-16T00:32:41Z")

</div>

Hi everyone, this is my first post.

I’m reorganizing a rails app to use RESTful routes. I have a users  
controller that’s mapped RESTfully. Before the switch to REST I had  
three separate actions to display a form to edit (on GET) and update  
(on POST) personal info, email address, and password. While I’ve  
managed to safely consolidate the update code for the three actions  
into a single RESTful update action, I’m wondering what’s the easiest  
way to do the following:

/users/1/edit/email  
/users/1/edit/password  
/users/1/edit/personal

I know that I could add this in routes.rb:  
map.connect ‘users/:id/edit/:what’, :controller =\> ‘users’, :action =\>  
‘edit’  
and handle which template is rendered in the controller like so:  
def edit  
if params[:what] == ‘email’  
# Render email template  
elsif params[:what] == ‘password’  
# Render password template  
elsif params[:what] == ‘personal’  
# Render personal template  
else  
# Render generic edit template  
end  
end

But let’s say for some completely arbitrary reason I want actions in  
the users controller named email password and personal that respond to  
the above routes. Is there any way to incorporate this mapping within  
map.resources?

I tried something like:  
map.resources :articles, :new =\> {:preview =\> :post}  
but with :edit…  
map.resources :users, :edit {:email =\> :get, :password  
=\> :get, :personal =\> :get}  
and it doesn’t work. I can understand why the former works and the  
latter doesn’t but was wondering if it is in fact possible to  
configure the desired route within map.resources. Or do you think the  
present solution is sufficient (in that it is good/adequate practice)?

Generally speaking, how would you go about coding a RESTful controller  
where a monolithic edit action (or more precisely template) doesn’t  
fit the bill?

Thanks for all of your help.
