# How to redirect back from action called from multiple controllers?

**URL:** <https://www.ruby-forum.com/t/how-to-redirect-back-from-action-called-from-multiple-controllers/142420>\
**Category:** Rails\
**Created:** [July 7, 2008, 8:55pm UTC](https://www.ruby-forum.com/t/how-to-redirect-back-from-action-called-from-multiple-controllers/142420 "2008-07-07T20:55:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [July 7, 2008, 8:55pm UTC](https://www.ruby-forum.com/t/how-to-redirect-back-from-action-called-from-multiple-controllers/142420/1 "2008-07-07T20:55:40Z")

</div>

Hi,

I’ve got a model i.e. Ticket, which has it’s own edit page. There’s  
also i.e. Report controller which has a view where I can edit i.e. one  
field of Ticket and Project controller where I can edit other field of  
Ticket object.

The question is: how to use only one update method in Ticket  
controller and write redirect part in a simple way, so it will  
redirect back to the action from which it was called (or execute some  
rjs)?

Should I send some additional parameter or use HTTP\_REFERER and make  
case statement for redirecting/rendering rjs? Is there some simpler  
way?

Regards

---

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [July 7, 2008, 9:16pm UTC](https://www.ruby-forum.com/t/how-to-redirect-back-from-action-called-from-multiple-controllers/142420/2 "2008-07-07T21:16:40Z")

</div>

On Jul 7, 7:42 pm, szimek [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> Should I send some additional parameter or use HTTP\_REFERER and make  
> case statement for redirecting/rendering rjs? Is there some simpler  
> way?

redirect\_to :back will do the referrer thing for you.

Fred

---

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [July 7, 2008, 9:29pm UTC](https://www.ruby-forum.com/t/how-to-redirect-back-from-action-called-from-multiple-controllers/142420/3 "2008-07-07T21:29:33Z")

</div>

On 7 Lip, 21:15, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Jul 7, 7:42 pm, szimek [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:\> Hi,
> 
> > Should I send some additional parameter or use HTTP\_REFERER and make  
> > case statement for redirecting/rendering rjs? Is there some simpler  
> > way?
> 
> redirect\_to :back will do the referrer thing for you.
> 
> Fred

Thanks.

This will work for html, s half of the problem is gone 🙂 But what  
about ajax request where I need to render specific rjs file?
