# Cleaning and Drying up controllers with postback actions

**URL:** <https://www.ruby-forum.com/t/cleaning-and-drying-up-controllers-with-postback-actions/110142>\
**Category:** Rails\
**Created:** [July 23, 2007, 7:24pm UTC](https://www.ruby-forum.com/t/cleaning-and-drying-up-controllers-with-postback-actions/110142 "2007-07-23T19:24:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![turnkeytraders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ba8739/32.png) [@turnkeytraders](https://www.ruby-forum.com/u/turnkeytraders)\
**Post date:** [July 23, 2007, 7:24pm UTC](https://www.ruby-forum.com/t/cleaning-and-drying-up-controllers-with-postback-actions/110142/1 "2007-07-23T19:24:24Z")

</div>

Hello,

I am trying to clean and dry up my controllers with my postbacks with  
the following code in my controller:

def edit  
@music = Music.find\_by\_id(params[:id]) || Music.new  
if request.post?  
@music.attributes = params[:music]  
redirect\_to :controller =\> ‘client’, :action =\> ‘show’, :id =\>  
session[:client] and return if @music.save  
end  
end

Now when I create a new album, it works fine, but when I try to edit it,  
this is the error I get:

no route found to match “/music/edit/edit/3”

Why isn’t my code doing my edit properly?

Thanks,  
M

---

<div class="post-metadata">

**Author:** ![turnkeytraders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ba8739/32.png) [@turnkeytraders](https://www.ruby-forum.com/u/turnkeytraders)\
**Post date:** [July 26, 2007, 12:46am UTC](https://www.ruby-forum.com/t/cleaning-and-drying-up-controllers-with-postback-actions/110142/2 "2007-07-26T00:46:02Z")

</div>

you might want to skip this recipe, since it no longer applies for  
RESTful routes… New and edit now use separate actions…

Mike

---

<div class="post-metadata">

**Author:** ![turnkeytraders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ba8739/32.png) [@turnkeytraders](https://www.ruby-forum.com/u/turnkeytraders)\
**Post date:** [July 26, 2007, 1:20am UTC](https://www.ruby-forum.com/t/cleaning-and-drying-up-controllers-with-postback-actions/110142/3 "2007-07-26T01:20:48Z")

</div>

Mike G. wrote:

> you might want to skip this recipe, since it no longer applies for  
> RESTful routes… New and edit now use separate actions…
> 
> Mike

Oh ok thanks.
