It''s expected that you render or redirect in the filter before you
cause it
to halt. If you don''t render or redirect, how is your user supposed to
know
that something went wrong or how to fix it. For example, a login_required
filter would redirect the user to the login url so that they can login and
return to the page they were originally trying to access.
Hope that helps,
Martin
On 1/5/07, Andrew Kaspick <akaspick@gmail.com>
wrote:>
>
> I was wondering if this is a bug or perhaps an issue with how I''m
using
> filters.
>
> When a filter chain halts, nothing is sent back to the browser by default.
>
> During tests, if a filter chain halts, the following error occurs
> because the response has no body.
>
> NoMethodError: You have a nil object when you didn''t expect it!
> You might have expected an instance of Array.
> The error occurred while evaluating nil.split
> actionpack/lib/action_controller/integration.rb:291:in
`parse_result''
> actionpack/lib/action_controller/integration.rb:271:in
`process''
> actionpack/lib/action_controller/integration.rb:152:in `get''
> actionpack/lib/action_controller/integration.rb:498:in `get''
>
> Now I can add something like render(:nothing => true, :status => 401)
> to my filters if they fail, but that makes things look a bit messy.
>
> Is this a bug in the integration code? Or am I doing something wrong?
>
> Thanks,
> Andrew
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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 rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---