Is it possible to include / use Application Helper methods inside of an config/initializers/browser_blocker.rb?
I am using the browser gem to detect and block older non modern browsers.
Rails.configuration.middleware.use Browser::Middleware do
include ApplicationHelper
redirect_to :controller => 'error', :action => 'browser-upgrade-required' if browser_is_not_supported
end
Helper method I am currently working with:
# test browser version
def browser_is_not_supported
return true unless browser.modern?
return true if browser.chrome? && browser.version.to_i < ENV['BROWSER_BASE_VERSION_GOOGLE'].to_i
return true if browser.firefox? && browser.version.to_i < ENV['BROWSER_BASE_VERSION_FIREFOX'].to_i
return true if browser.safari? && browser.version.to_i < ENV['BROWSER_BASE_VERSION_SAFARI'].to_i
return true if browser.opera? && browser.version.to_i < ENV['BROWSER_BASE_VERSION_OPERA'].to_i
return true if browser.ie? && browser.version.to_i < ENV['BROWSER_BASE_VERSION_MSFT'].to_i
end
ApplicationHelperfunctionality there? It would be best to just use the specific modules instead, hard to give an example since your example is not using any helper methods