hi, I tried to redirect rails to show action by passing controller, action, and params. However, rails ignores the name of action totally! what I got is http://mysite/controllername/paramId so i have error message.... here is the action code I used: def update @tip = current_user.tips.find(params[:id]) @tip.attributes = params[:tip] @tip.category_ids = params[:categories] @tip.tag_with(params[:tags]) if params[:tags] if @tip.save flash[:notice] = ''Tip was successfully updated.'' redirect_to :controller=>''tips'', :action => ''show'', :id => @tip.permalink else render :action => ''edit'' end end -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Amar Daxini
2010-Jun-16 08:56 UTC
Re: redirect_to :controller=>''tips'', :action => ''show''
John Useast wrote:> > hi, > > I tried to redirect rails to show action by passing controller, action, > and params. However, rails ignores the name of action totally! > > what I got is http://mysite/controllername/paramId > > > def update > @tip = current_user.tips.find(params[:id]) > @tip.attributes = params[:tip] > @tip.category_ids = params[:categories] > @tip.tag_with(params[:tags]) if params[:tags] > > > if @tip.save > flash[:notice] = ''Tip was successfully updated.'' > redirect_to :controller=>''tips'', :action => ''show'', :id => > @tip.permalink > else > render :action => ''edit'' > end > endyou can try redirect_to(tip_path(@tip)) Amar Daxini http://railstech.com -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2010-Jun-16 09:00 UTC
Re: redirect_to :controller=>''tips'', :action => ''show''
On Jun 11, 11:15 pm, John Useast <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> hi, > > I tried to redirect rails to show action by passing controller, action, > and params. However, rails ignores the name of action totally! > > what I got ishttp://mysite/controllername/paramId >With a normal set of restful routes (ie if you''ve got map.resources :tips in your routes files), the normal show url for the tip with id 123 IS /tips/123 Fred> so i have error message.... > > here is the action code I used: > > def update > @tip = current_user.tips.find(params[:id]) > @tip.attributes = params[:tip] > @tip.category_ids = params[:categories] > @tip.tag_with(params[:tags]) if params[:tags] > > if @tip.save > flash[:notice] = ''Tip was successfully updated.'' > redirect_to :controller=>''tips'', :action => ''show'', :id => > @tip.permalink > else > render :action => ''edit'' > end > end > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.