Web Images Videos Maps News Groups Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Change in ActionController's filter API (cross-posted to Oceania list)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ryan Allen  
View profile  
 More options Feb 11 2008, 1:01 pm
From: Ryan Allen <r...@yeahnah.org>
Date: Sun, 10 Feb 2008 18:01:51 -0800 (PST)
Local: Mon, Feb 11 2008 1:01 pm
Subject: Change in ActionController's filter API (cross-posted to Oceania list)
People,

I'm not sure if this is very widely known, but 4 months DHH changed
the API for ActionController's filters [1]. Since for ever you could
halt the filter chain by returning false. This was (and still is)
advice given in the official AWDWR book by the PragProgs [2].

It is imperative that if you're using this method of filter chain
halting (and you've upgraded to Rails 2.0) that you update your code-
base ASAP, i.e.:

  before_filter :stop_nasty_buggers

  def stop_nasty_buggers
    false
  end

now becomes:

  before_filter :stop_nasty_buggers

  def stop_nasty_buggers
    halt(404)
  end

Returning false don't to jack no more. Note that redirecting and
rendering in a filter method still halts execution. The current
documentation point this out (halt on redirect or render) but doesn't
mention the deprecation of returning false, which makes this somewhat
ambiguous in my opinion.

There's no mention of this deprecation on the Rails website [3], no
mention of this API change in the official 'we iz got Rails 2.0 teh
r0x0r' post [4].

Was this announced anywhere (besides the ActionPack CHANGELOG) or do I
need my head checked for memory impairment?

Ryan.

P.S. if you were good boys and girls and had tests for your filters
(i.e. not like me), you'd have caught this in your builds.

[1] http://dev.rubyonrails.org/changeset/7984
[2] http://pragprog.com/titles/rails2
[3] http://www.rubyonrails.org/deprecation
[4] http://weblog.rubyonrails.org/2007/12/7/rails-2-0-it-s-done


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ryan Allen  
View profile  
 More options Feb 11 2008, 1:08 pm
From: Ryan Allen <r...@yeahnah.org>
Date: Sun, 10 Feb 2008 18:08:24 -0800 (PST)
Local: Mon, Feb 11 2008 1:08 pm
Subject: Re: Change in ActionController's filter API (cross-posted to Oceania list)

>   def stop_nasty_buggers
>     halt(404)
>   end

Sorry, make that:

def stop_nasty_buggers
  head(404)
end

Ryan.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google