# Is there a way to know what action you're in?

**URL:** <https://www.ruby-forum.com/t/is-there-a-way-to-know-what-action-youre-in/112436>\
**Category:** Rails\
**Created:** [August 18, 2007, 9:30pm UTC](https://www.ruby-forum.com/t/is-there-a-way-to-know-what-action-youre-in/112436 "2007-08-18T21:30:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![charlie\_caroff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a587f6/32.png) [@charlie\_caroff](https://www.ruby-forum.com/u/charlie_caroff)\
**Post date:** [August 18, 2007, 9:30pm UTC](https://www.ruby-forum.com/t/is-there-a-way-to-know-what-action-youre-in/112436/1 "2007-08-18T21:30:57Z")

</div>

I have a partial that is placed in many different pages, or, in rails  
terms, participates in many different actions.

So, the partial \_list.rhtml is on

./admin/show.rhtml

and it’s also on

./admin/find.rhtml

I want the partial \_list.rhtml to have different behaviors for show  
and find. Is there an object available on a page, that contains the  
controller and action for that page?

Charlie

---

<div class="post-metadata">

**Author:** ![charlie\_caroff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a587f6/32.png) [@charlie\_caroff](https://www.ruby-forum.com/u/charlie_caroff)\
**Post date:** [August 18, 2007, 9:34pm UTC](https://www.ruby-forum.com/t/is-there-a-way-to-know-what-action-youre-in/112436/2 "2007-08-18T21:34:57Z")

</div>

If you just want to know the action that was requested in the url,  
params[:action] will have it

charlie caroff wrote:

> I want the partial \_list.rhtml to have different behaviors for show  
> and find. Is there an object available on a page, that contains the  
> controller and action for that page?
> 
> Charlie
> 
> >

–  
Sincerely,

William P.

[http://www.billpratt.net](http://www.billpratt.net)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![charlie\_caroff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a587f6/32.png) [@charlie\_caroff](https://www.ruby-forum.com/u/charlie_caroff)\
**Post date:** [August 18, 2007, 10:24pm UTC](https://www.ruby-forum.com/t/is-there-a-way-to-know-what-action-youre-in/112436/3 "2007-08-18T22:24:59Z")

</div>

Thank you. And, for the sake of other newbies like me,  
params[:controller] has the controller name in it.

Charlie

---

<div class="post-metadata">

**Author:** ![charlie\_caroff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a587f6/32.png) [@charlie\_caroff](https://www.ruby-forum.com/u/charlie_caroff)\
**Post date:** [August 18, 2007, 10:29pm UTC](https://www.ruby-forum.com/t/is-there-a-way-to-know-what-action-youre-in/112436/4 "2007-08-18T22:29:59Z")

</div>

Sorry about that, I missed the part about the controller. Not enough  
coffee yet 🙂

charlie caroff wrote:

> > > and it’s also on  
> > > Sincerely,
> > 
> > William P.
> > 
> > [http://www.billpratt.net](http://www.billpratt.net)  
> > removed\_email\_address@domain.invalid
> 
> >

–  
Sincerely,

William P.

[http://www.billpratt.net](http://www.billpratt.net)  
removed\_email\_address@domain.invalid
