# Can 2 actions use a single view?

**URL:** <https://www.ruby-forum.com/t/can-2-actions-use-a-single-view/76504>\
**Category:** Rails\
**Created:** [November 19, 2006, 8:44pm UTC](https://www.ruby-forum.com/t/can-2-actions-use-a-single-view/76504 "2006-11-19T20:44:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![holly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/48db29/32.png) [@holly](https://www.ruby-forum.com/u/holly)\
**Post date:** [November 19, 2006, 8:44pm UTC](https://www.ruby-forum.com/t/can-2-actions-use-a-single-view/76504/1 "2006-11-19T20:44:09Z")

</div>

I have 2 different actions, when they are complete, can they both be  
sent to the same view?

---

<div class="post-metadata">

**Author:** ![holly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/48db29/32.png) [@holly](https://www.ruby-forum.com/u/holly)\
**Post date:** [November 19, 2006, 8:58pm UTC](https://www.ruby-forum.com/t/can-2-actions-use-a-single-view/76504/2 "2006-11-19T20:58:18Z")

</div>

would i use a Partial Page Template ?

---

<div class="post-metadata">

**Author:** ![holly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/48db29/32.png) [@holly](https://www.ruby-forum.com/u/holly)\
**Post date:** [November 19, 2006, 8:59pm UTC](https://www.ruby-forum.com/t/can-2-actions-use-a-single-view/76504/3 "2006-11-19T20:59:16Z")

</div>

On 11/20/06, holly [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have 2 different actions, when they are complete, can they both be  
> sent to the same view?

Check out ‘redirect\_to’ and ‘render’ in the Rails API docs.

---

<div class="post-metadata">

**Author:** ![holly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/48db29/32.png) [@holly](https://www.ruby-forum.com/u/holly)\
**Post date:** [November 20, 2006, 9:38am UTC](https://www.ruby-forum.com/t/can-2-actions-use-a-single-view/76504/4 "2006-11-20T09:38:20Z")

</div>

unknown wrote:

> On 11/20/06, holly [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > I have 2 different actions, when they are complete, can they both be  
> > sent to the same view?
> 
> Check out ‘redirect\_to’ and ‘render’ in the Rails API docs.

Controller.rb

def myaction1  
.  
.  
.  
render :template =\> ‘yourview’  
end

def myaction2  
…  
…  
…  
render :template =\> ‘yourview’  
end

hth…

---

<div class="post-metadata">

**Author:** ![holly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/48db29/32.png) [@holly](https://www.ruby-forum.com/u/holly)\
**Post date:** [November 20, 2006, 9:46am UTC](https://www.ruby-forum.com/t/can-2-actions-use-a-single-view/76504/5 "2006-11-20T09:46:21Z")

</div>

thankyou

---

<div class="post-metadata">

**Author:** ![holly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/48db29/32.png) [@holly](https://www.ruby-forum.com/u/holly)\
**Post date:** [November 20, 2006, 2:45pm UTC](https://www.ruby-forum.com/t/can-2-actions-use-a-single-view/76504/6 "2006-11-20T14:45:38Z")

</div>

On 11/20/06, holly [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> would i use a Partial Page Template ?

Well a partial is really just a way to keep your views tidy by not  
repeating the same chunk of code across different views. So partials  
are largely about the ‘view’ end of things whereas your initial query  
re 2 different actions using the same view relates more to the  
controller side of things.

Partials come into play as a way of keeping things DRY - so if you had  
a User model and an Address model, and a User has\_many addresses,  
there might be more than one place in your application where you want  
to display a list of a user’s addresses.

Rather than repeat the code that iterates through the array of a  
user’s addresses, you would extract this as a partial and then render  
that partial in any view where you wanted to display the list.

So a partial is just that - a ‘partial’ view, whereas your initial  
question seemed to imply that you wanted 2 controller actions to  
render the exact same view.
