Matthew Lagace
2007-Jul-23 17:24 UTC
Cleaning and Drying up controllers with postback actions
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mike Garey
2007-Jul-23 17:33 UTC
Re: Cleaning and Drying up controllers with postback actions
you might want to skip this recipe, since it no longer applies for RESTful routes.. New and edit now use separate actions.. Mike On 7/23/07, Matthew Lagace <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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 > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matthew Lagace
2007-Jul-25 23:20 UTC
Re: Cleaning and Drying up controllers with postback actions
Mike Garey wrote:> you might want to skip this recipe, since it no longer applies for > RESTful routes.. New and edit now use separate actions.. > > MikeOh ok thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---