Hey everyone,
Just a quick one, how to redirect to root from a controller:
return Redirect(Url.Content("~/"));
For more info, checkout this Stackoverflow post: http://stackoverflow.com/a/10292039/522859
Hey everyone,
Just a quick one, how to redirect to root from a controller:
return Redirect(Url.Content("~/"));
For more info, checkout this Stackoverflow post: http://stackoverflow.com/a/10292039/522859
Ran into another flash notice issue, my messages were not disappearing after the first view. My code was as follows:
#Create flash warning flash[:warning] = ("This product has been replaced: " +new_product.title + "").html_safe
It turns out that all you have to do to fix this issue is the following:
flash.now[:warning] = ("This product has been replaced: " +new_product.title + "").html_safe
This blog gives a brief overview of when to use flash.now[notice] and when to use flash[:notice]. A basic rule of thumb is that if you’re using a redirect, use flash[:notice], if you’re simply rendering a view, use flash.now[:notice].
This wasn’t one I had encountered before and unfortunately Google couldn’t give me anything to cheat off. Luckily, a quick review of the server log revealed the following message just before it closed the connection:
#Redirect to edit location path redirect_to '/locations/edit'
Hopefully this’ll be able to help someone else out there, Good Luck!
No HTTP_REFERER was set in the request to this action, so redirect_to :back could not be called successfully. If this is a test, make sure to specify request.env[“HTTP_REFERER”].
#Redirect_to_back def go_back #Attempt to redirect redirect_to :back #Catch exception and redirect to root rescue ActionController::RedirectBackError redirect_to root_path end
#Redirect user to previous page go_back
#Redirect user to previous page go_back #Return to prevent multiple redirects return