Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect One Controller to another Controller

I have two controllers users & movies. All, I want to do, redirect from user#something to movie#something. is it possible??

like image 311
Adnan Avatar asked Jul 01 '12 14:07

Adnan


People also ask

How do I redirect to another controller?

Use this: return RedirectToAction("LogIn", "Account", new { area = "" }); This will redirect to the LogIn action in the Account controller in the "global" area.

How do I redirect to ActionResult?

RedirectResult is an ActionResult that returns a Found (302), Moved Permanently (301), Temporary Redirect (307), or Permanent Redirect (308) response with a Location header to the supplied URL. It will redirect us to the provided URL, it doesn't matter if the URL is relative or absolute.


1 Answers

redirect_to controller: :controllername, action: :actionname' 

where controllername is the name of your controller and actionname is the name of your action. this works for rails 4 but should also work for older versions of rails

like image 181
Peter Piper Avatar answered Sep 18 '22 15:09

Peter Piper