Issue with before_filter and redirect_to

Hi, I’ve a small problem here :

class ApplicationController < ActionController::Base
def maintenance
redirect_to :controller => ‘static’, :action => ‘maintenance’
end
end

class CompteController < ApplicationController
before_filter :maintenance
end

I can see on WebRick logs that there is a loop and /static/maintenance
is called forever. Why ??

before_filter :maintenance is only used with the CompteController

Thanks

I did a try : when maintenance() method is placed in CompteController
instead of ApplicationController it works…

I don’t understand why a derived class can’t set a before_filter using
an parent class method…

Any idea ?

It smells like Yor’re calling over and over the maintenance action
defined in ApplicationController.
Probably the ‘maintenance’ action which is replying in static
controller is the one defined in ApplicationController and not the one
you expect.
breakpoint’ll be your friend.

Paolo

Paolo N. wrote:

It smells like Yor’re calling over and over the maintenance action
defined in ApplicationController.
Probably the ‘maintenance’ action which is replying in static
controller is the one defined in ApplicationController and not the one
you expect.
breakpoint’ll be your friend.

Paolo

100% right Paolo !! Thanks a lot ! I’ve changed action name used in the
redirect_to and it works.

A rail’s bug ??

Well ApplicationController does have an action called maintenance, so
rails might not be completely wacky. Out of interest if you mark the
maintenance method in ApplicationController as protected, does that also
solve the problem ?

Fred

Frederick C. wrote:

Well ApplicationController does have an action called maintenance, so
rails might not be completely wacky. Out of interest if you mark the
maintenance method in ApplicationController as protected, does that also
solve the problem ?

Fred

I did not tried with protecting but I’ve changed the method’s name in
the ApplicationController and put back the action name of :action to
“maintenance” and it works also…

So, as you said there something between that maintenance method defined
in rails and mine…

Thanks !