Rup
2009-Dec-23 17:13 UTC
ActionController::DoubleRenderError -- how to redirect to different paths based on if else condition in rails??
def checkout login_required #if the user logged in has billing and shipping address on file, show edit page else show new page. @useraddress=UserAddress.find_by_user_id(current_user.id) if @useraddress then #user''s address exist redirect_to edit_user_address_path(@useraddress.id) and return else #user''s address doesn''t exist redirect_to new_user_address_path and return end end The above code is giving me DoubleRenderError. I want to go to edit_user_address_path if the if condition is true else I want to go to new_user_address_path to create one. Can any one help me? I don''t see any good documentation on this. Thanks -- 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.
Narendra sisodiya
2009-Dec-23 17:51 UTC
Re: ActionController::DoubleRenderError -- how to redirect to different paths based on if else condition in rails??
what login_required method do here? I mean is this also redirecting to some other url ?? ~Naren On Wed, Dec 23, 2009 at 10:43 PM, Rup <rnarayan08-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> def checkout > login_required > #if the user logged in has billing and shipping address on file, > show edit page else show new page. > > @useraddress=UserAddress.find_by_user_id(current_user.id) > > if @useraddress then #user''s address exist > redirect_to edit_user_address_path(@useraddress.id) and return > else #user''s address doesn''t exist > redirect_to new_user_address_path and return > end > > end > > The above code is giving me DoubleRenderError. I want to go to > edit_user_address_path if the if condition is true else I want to go > to new_user_address_path to create one. > Can any one help me? I don''t see any good documentation on this. > > Thanks > > -- > > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > >-- 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.
pharrington
2009-Dec-23 18:13 UTC
Re: ActionController::DoubleRenderError -- how to redirect to different paths based on if else condition in rails??
On Dec 23, 12:13 pm, Rup <rnaraya...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> def checkout > login_required > #if the user logged in has billing and shipping address on file, > show edit page else show new page. > > @useraddress=UserAddress.find_by_user_id(current_user.id) > > if @useraddress then #user''s address exist > redirect_to edit_user_address_path(@useraddress.id) and return > else #user''s address doesn''t exist > redirect_to new_user_address_path and return > end > > end > > The above code is giving me DoubleRenderError. I want to go to > edit_user_address_path if the if condition is true else I want to go > to new_user_address_path to create one. > Can any one help me? I don''t see any good documentation on this. > > Thanksreturn false after you redirect. -- 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.