Undefined method "redirect_to" in before_filter

Code sample:

class SomeController < ApplicationController
before_filter do |c|
add_crumb "Blah", "/blah" #breadcrumbs plugin
redirect_to :controller => "foo", :action => "bar" unless c.send
(:has_package?)
end

# Rest of the controller...

private

def has_package?
# A bunch of logic work to check to make sure
# somebody's session contains certain variables
# returns ONLY true or false.
end

The problem I'm having is that I'm getting "undefined method" errors
for redirect_to. This confuses me since SomeController inherits from
ApplicationController which inherits from ActionController::Base. Any
idea what's causing this problem? I'm thinking this is a scope issue
somehow, but I'm not sure why it's failing like this.

Thanks.

One thing I forgot to mention. I've tweaked it so that I CAN get it
to work by calling the redirect_to method while inside has_package? -
so basically it looks like this:

def has_package?
# if conditions
redirect_to :controller => "foo", :action => "bar"
# else
redirect_to :controller => "foo", :action => "bar"
# end
end

So before_filter is calling this method which CAN access redirect_to
as inherited from ActionController::Base. I'm just confused as to why
I have some obvious inheritance issues here.

with a before_filter using the block syntax self is the SomeController
class itself, but redirect_to is an instance method. Much as you have
to call your has_package method on the controller instance that is
yielded to the block you must also call redirect_to on that object.

Fred

So then would the syntax be:

c.redirect_to ...

?

Thanks Fred - for the record, you're the man :wink:

So then would the syntax be:

c.redirect_to ...

Yup (unless the method was protected/private in which case you could
use send, but i don;t think it is)

Fred