# Passing parameters to private methods with before\_filter

**URL:** <https://www.ruby-forum.com/t/passing-parameters-to-private-methods-with-before-filter/120324>\
**Category:** Rails\
**Created:** [November 15, 2007, 7:55pm UTC](https://www.ruby-forum.com/t/passing-parameters-to-private-methods-with-before-filter/120324 "2007-11-15T19:55:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f04885/32.png) [@gete](https://www.ruby-forum.com/u/gete)\
**Post date:** [November 15, 2007, 7:55pm UTC](https://www.ruby-forum.com/t/passing-parameters-to-private-methods-with-before-filter/120324/1 "2007-11-15T19:55:49Z")

</div>

Hello,

I was wondering if anybody can show me how to pass parameters to a  
Private method with before\_filter.  
I’ve tried doing the proc blocked way with

before\_filter {|c| c.private\_method(params)} …but this throws an  
exception when the method is private.

The rails api says that using the standard symbol reference  
( before\_filter :private\_method) is for private and protected methods  
which leads me to assume that using the block method only works for  
public methods. Does anybody know how I might pass parameters to a  
private method with before\_filter?

Thanks  
Greg T.

---

<div class="post-metadata">

**Author:** ![gete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f04885/32.png) [@gete](https://www.ruby-forum.com/u/gete)\
**Post date:** [November 15, 2007, 9:13pm UTC](https://www.ruby-forum.com/t/passing-parameters-to-private-methods-with-before-filter/120324/2 "2007-11-15T21:13:40Z")

</div>

Hi Bob,

That worked…thanks so much.

Greg

---

<div class="post-metadata">

**Author:** ![gete](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/f04885/32.png) [@gete](https://www.ruby-forum.com/u/gete)\
**Post date:** [November 15, 2007, 8:03pm UTC](https://www.ruby-forum.com/t/passing-parameters-to-private-methods-with-before-filter/120324/3 "2007-11-15T20:03:27Z")

</div>

On Nov 15, 2007 1:55 PM, gete [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hello,
> 
> I was wondering if anybody can show me how to pass parameters to a  
> Private method with before\_filter.  
> I’ve tried doing the proc blocked way with
> 
> before\_filter {|c| c.private\_method(params)} …but this throws an  
> exception when the method is private.

You can use send:

c.send(:private\_method, params)
