This is one way to do this:
module BrowserUtil
def self.supported?(browser)
end
end
and wrap this from ApplicationHelper for use in views
module ApplicationHelper
def is_browser_supported?
BrowserUtil.supported?(browser)
end
end
in middleware
Rails.configuration.middleware.use Browser::Middleware do
unless BrowserUtil.supported?(browser)
redirect_to :controller => 'error', :action => 'browser-upgrade-required'
end
end
UPDATE: it should not be in a separate module (BrowserUtil)
module ApplicationHelper
def self.foo
"FOO"
end
def foo
ApplicationHelper.foo
end
end
in using middleware
ApplicationHelper.foo
in views he would use the included method
foo