# Filters

**URL:** <https://www.ruby-forum.com/t/filters/142088>\
**Category:** Rails\
**Created:** [July 3, 2008, 10:29am UTC](https://www.ruby-forum.com/t/filters/142088 "2008-07-03T10:29:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jschank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/96bed5/32.png) [@jschank](https://www.ruby-forum.com/u/jschank)\
**Post date:** [July 3, 2008, 10:29am UTC](https://www.ruby-forum.com/t/filters/142088/1 "2008-07-03T10:29:49Z")

</div>

Hello,  
I’m new to rails and ruby. I’m reading Simply Rails 2, and working  
through the chapters to learn how to use rails.

– backstory –  
We’re on chapter 8 or so where we are learning about filters.

At this step we are to add a before\_filter, like so:

before\_filter :login\_required, :only =\> [:new, :create]

I’ve looked around for details, but the rails docs offer this:

before\_filter(\*filters, &block)  
Alias for append\_before\_filter

and:

append\_before\_filter(\*filters, &block)  
The passed filters will be appended to the filter\_chain and will  
execute before the action on this controller is performed.  
This method is also aliased as before\_filter

– actual question –

What I want to know is: Given this documentation, how would a user  
know that there is an :only, and an :except parameter, and what they  
take?

Is it some ruby feature of &block paramters that I can toss in a hash?  
How do I find out what the valid keys are for such hash, and what they  
do?

Thanks,  
John Schank

---

<div class="post-metadata">

**Author:** ![jschank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/96bed5/32.png) [@jschank](https://www.ruby-forum.com/u/jschank)\
**Post date:** [July 3, 2008, 11:06am UTC](https://www.ruby-forum.com/t/filters/142088/2 "2008-07-03T11:06:14Z")

</div>

On 3 Jul 2008, at 07:05, jschank wrote:

> – actual question –
> 
> What I want to know is: Given this documentation, how would a user  
> know that there is an :only, and an :except parameter, and what they  
> take?  
> You probably wouldn’t. :only and :except should be arrays of actions  
> that filter should apply or not apply to.  
> Some thing has gone funny with the docs on [api.rubyonrails.org](http://api.rubyonrails.org), as  
> there’s a whole swathe of info about filters that has gone. You can  
> still read it here.

> Is it some ruby feature of &block paramters that I can toss in a hash?  
> How do I find out what the valid keys are for such hash, and what they  
> do?

No, the &block stuff gives the method any block specified as a proc  
object.

the magic hash parameter is swallowed up by the parameter with a splat

Fred

---

<div class="post-metadata">

**Author:** ![jschank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/96bed5/32.png) [@jschank](https://www.ruby-forum.com/u/jschank)\
**Post date:** [July 3, 2008, 6:41pm UTC](https://www.ruby-forum.com/t/filters/142088/3 "2008-07-03T18:41:35Z")

</div>

Ah. Ok.  
Thanks for the reply.

I come from Java development, and I’ve been using Netbeans as my rails  
IDE (though I know you don’t actually need one) And one thing I really  
miss is the abilty to highlight a method and get pop up help about it.  
Or to have intellisense which shows the possible alternatives.

Following a tutorial book is all well and good, but it only shows you  
how to do specifically what the tutorial shows. I’m finding it a  
little bit difficult to see alternatives and possibilities in the  
Rails / Ruby docs.

I suppose I’ll be browsing here a lot more.  
🙂

On Jul 3, 5:05 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![jschank](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/96bed5/32.png) [@jschank](https://www.ruby-forum.com/u/jschank)\
**Post date:** [July 3, 2008, 7:00pm UTC](https://www.ruby-forum.com/t/filters/142088/4 "2008-07-03T19:00:57Z")

</div>

On 3 Jul 2008, at 17:40, jschank wrote:

> Ah. Ok.  
> Thanks for the reply.
> 
> I come from Java development, and I’ve been using Netbeans as my rails  
> IDE (though I know you don’t actually need one) And one thing I really  
> miss is the abilty to highlight a method and get pop up help about it.  
> Or to have intellisense which shows the possible alternatives.

The problem in this particular case is that the documentation got  
mashed. I don’t know netbeans, but i’d be surprised if it didn’t have  
some sort of documentation lookup. I use textmate as my editor and if  
I hit control H I get the rdoc for the method in question

Fred
