On 7/3/07, Jeff <[EMAIL PROTECTED]> wrote:
>
> On Jun 29, 10:43 pm, "Michael Koziarski" <[EMAIL PROTECTED]>
> wrote:
> > Edge Rails currently has a bug / misfeature regarding around filters
> > which don't yield, the intention is to support cases like this:
> >
> > around_filter :authorization_required
> >
> > def authorization_required
> >   if logged_in?
> >     yield
> >   else
> >     redirect_to authentication_url
> >   end
> > end
>
> Can I ask, without sounding like a *complete* idiot, what the intent
> of the yield statement would be in this scenario?  My understanding of
> around_filter is to run some code both before and after every action.
> There's already a defined sequence of events going on -- so what would
> one be yielding *to* ?

Around filters are like a wrapper for your action, where 'yield' is
the action.  This is one of the reasons we all love ruby, and why
rails would be really hard to implement in other languages.

If you don't yield it's just like a before filter returning false. Very handy.

AFAIK you should usually use around filters instead of before-filters
so you can clear whatever instance variables you just set (so that
they don't have the potential of leaking between requests in
production mode).

I use that idiom, and I haven't upgraded to edge rails yet.

Courtenay

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to