# RE: Passing a parameter to a before\_filter method

**URL:** <https://www.ruby-forum.com/t/re-passing-a-parameter-to-a-before-filter-method/49699>\
**Category:** Rails\
**Created:** [December 7, 2005, 8:52pm UTC](https://www.ruby-forum.com/t/re-passing-a-parameter-to-a-before-filter-method/49699 "2005-12-07T20:52:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HOGANBP](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/779978/32.png) [@HOGANBP](https://www.ruby-forum.com/u/HOGANBP)\
**Post date:** [December 7, 2005, 8:52pm UTC](https://www.ruby-forum.com/t/re-passing-a-parameter-to-a-before-filter-method/49699/1 "2005-12-07T20:52:03Z")

</div>

Can you use the session to store the parameter so you don’t have to pass  
anything?

---

<div class="post-metadata">

**Author:** ![HOGANBP](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/779978/32.png) [@HOGANBP](https://www.ruby-forum.com/u/HOGANBP)\
**Post date:** [December 8, 2005, 1:32pm UTC](https://www.ruby-forum.com/t/re-passing-a-parameter-to-a-before-filter-method/49699/2 "2005-12-08T13:32:59Z")

</div>

Thanks for the replies. The lambda didn’t want to work. I got a no  
method error. That was with the called function in application.rb and  
the before\_filter call in another file, which was a sub-sub-class of  
application.rb.

I ended up reorganizing my one or two bigger functions into three  
really small functions, and got things working.

–Alison

---

<div class="post-metadata">

**Author:** ![HOGANBP](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/779978/32.png) [@HOGANBP](https://www.ruby-forum.com/u/HOGANBP)\
**Post date:** [December 8, 2005, 4:42pm UTC](https://www.ruby-forum.com/t/re-passing-a-parameter-to-a-before-filter-method/49699/3 "2005-12-08T16:42:11Z")

</div>

Actually I got the lambda version wrong. It should look like

before\_filter lambda{|controller| controller.authorize(“admin”) }

Kent.

---

<div class="post-metadata">

**Author:** ![HOGANBP](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/779978/32.png) [@HOGANBP](https://www.ruby-forum.com/u/HOGANBP)\
**Post date:** [December 8, 2005, 5:23pm UTC](https://www.ruby-forum.com/t/re-passing-a-parameter-to-a-before-filter-method/49699/4 "2005-12-08T17:23:22Z")

</div>

Kent S. wrote:

> > the before\_filter call in another file, which was a sub-sub-class of  
> > application.rb.
> > 
> > I ended up reorganizing my one or two bigger functions into three  
> > really small functions, and got things working.

One other point - Rails is single threaded, so you can use class  
variables or globals to hold state within the life of a single request.  
I’ve seen this given as the answer to “how to make the current user  
accessible to models”.

regards

Justin
