From ce68cf6448555cb68cb06bbcc86fd63bde1edf48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dorian=20Mari=C3=A9?= Date: Sat, 15 May 2021 18:15:10 +0200 Subject: [PATCH] README: Use before_action instead of before_filter and format code before_filter is not defined in rails 6 --- README.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c5103d3..d9b21dc 100644 --- a/README.md +++ b/README.md @@ -34,12 +34,13 @@ You can easily set the locale used for i18n in a before-filter: ```ruby class SomeController < ApplicationController - before_filter :set_locale + before_action :set_locale private - def set_locale - I18n.locale = http_accept_language.compatible_language_from(I18n.available_locales) - end + + def set_locale + I18n.locale = http_accept_language.compatible_language_from(I18n.available_locales) + end end ``` @@ -49,7 +50,7 @@ If you want to enable this behavior by default in your controllers, you can just class ApplicationController < ActionController::Base include HttpAcceptLanguage::AutoLocale -#... + # ... end ``` @@ -71,7 +72,6 @@ Then you can access it from `env`: ``` ruby class YourAwesomeApp - def initialize(app) @app = app end @@ -82,7 +82,6 @@ class YourAwesomeApp [200, {}, ["Oh, you speak #{language}!"]] end - end ```