9
There's a gem, which appends a before_filter to a Rails app:
class Railtie < Rails::Railtie
initializer "..." do
ActiveSupport.on_load(:action_controller) do
ActionController::Base.send(:include, Filter)
...
module Filter
extend ActiveSupport::Concern
included do
append_before_filter :set_locale
end
def set_locale
....
And here's some controller in the app:
class DesktopsController < ApplicationController
before_filter :set_language_in_session
Now the problem with this is that the before_filter from the gem is being put in the filter chain before the before_filter from the DesktopsController:
DesktopsController._process_action_callbacks.select { |c| c.kind == :before }.collect { |filter| filter.filter }
=> [
[0] :set_locale,
[1] :set_language_in_session
]
How can I make the before_filter from the gem (set_locale) be put after all other filters? The secret probably lies in this line:
ActiveSupport.on_load(:action_controller) do
But I've tried different libraries without any luck...
Btw. Here's the full code of the gem. Ruby 1.9.2, Rails 3.0.5.