# Knowing the method from before\_filter

**URL:** <https://www.ruby-forum.com/t/knowing-the-method-from-before-filter/125960>\
**Category:** Rails\
**Created:** [January 14, 2008, 8:42am UTC](https://www.ruby-forum.com/t/knowing-the-method-from-before-filter/125960 "2008-01-14T08:42:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hsun](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/9fc348/32.png) [@hsun](https://www.ruby-forum.com/u/hsun)\
**Post date:** [January 14, 2008, 8:42am UTC](https://www.ruby-forum.com/t/knowing-the-method-from-before-filter/125960/1 "2008-01-14T08:42:23Z")

</div>

I would like to know the method that will be called from  
before\_filter, is it possible?

for example

class TestController \< ApplicationController

before\_filter :tell\_method\_name

protected  
def tell\_method\_name  
#tell the name of the method that is going to be called  
end

def index  
…  
end

end

so if i call [http://localhost:3000/test](http://localhost:3000/test), it will call tell\_method\_name  
and display “index”, how can i do it in here?

---

<div class="post-metadata">

**Author:** ![hsun](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/9fc348/32.png) [@hsun](https://www.ruby-forum.com/u/hsun)\
**Post date:** [January 14, 2008, 9:53am UTC](https://www.ruby-forum.com/t/knowing-the-method-from-before-filter/125960/2 "2008-01-14T09:53:34Z")

</div>

On 14 Jan 2008, at 07:41, hsun wrote:

> I would like to know the method that will be called from  
> before\_filter, is it possible?

You can use action\_name to get the name of the current action.

Fred

---

<div class="post-metadata">

**Author:** ![hsun](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/9fc348/32.png) [@hsun](https://www.ruby-forum.com/u/hsun)\
**Post date:** [January 14, 2008, 2:21pm UTC](https://www.ruby-forum.com/t/knowing-the-method-from-before-filter/125960/3 "2008-01-14T14:21:14Z")

</div>

Thank you very much

On Jan 14, 3:52 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
