Forum: Ruby on Rails class filter: cannot call protected controller methods

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B45eab4f18aa1bb2a44d6e657531a642?d=identicon&s=25 Alain Ravet (aravet)
on 2006-05-17 13:29
Greetins all,

I'm rewriting a filter from the method form to a class filter.(see
below)

Problem: some controller - redirect_to - and route - *_url - methods are
protected (redirect_to, f.ex.), and cannot be called.

Is this intended?
Is there a solution workaround?

TIA

Alain

BEFORE:
-----------
    before_filter   :login_required, :except => [:welcome,:login]
    def login_required
        unless current_user
            session[:jumpto]  = request.parameters
            redirect_to login_invite_url
        end
    end


AFTER (does not compile)
-----------

    class AuthenticationFilter
        def self.filter(controller)

            login_required =
['welcome','login'].include?(controller.action_name)
            if login_required &&  !controller.current_user
                controller.session[:jumpto]  =
controller.request.parameters
                controller.redirect_to controller.login_invite_url
<<<<------- ERROR : DOES NOT COMPILE !!
            end
        end
    end
    before_filter   AuthenticationFilter
This topic is locked and can not be replied to.