Rails before_filter on subclasses beeing called twice
- by rubenfonseca
Hi! I'm at Rails 2.3.5 and I have this problem:
class BaseController < ApplicationController
before_filter :foo, :only => [:index]
end
class ChildController < BaseController
before_filter :foo, :only => [:index, :show, :other, :actions]
end
The problem is that on ChildController, the :foo before filter gets called twice.
I've tried a number of workarounds around this problem. If I don't include the :index action on the child, it never gets called for that action.
The solution I found works, but is very very ugly
skip_before_filter :foo
before_filter :foo, :only => [:index, :show, :other, :actions]
Is there a better way to solve this problem? Thanks