Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README: Use before_action instead of before_filter and format code #74

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand All @@ -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
```

Expand All @@ -71,7 +72,6 @@ Then you can access it from `env`:

``` ruby
class YourAwesomeApp

def initialize(app)
@app = app
end
Expand All @@ -82,7 +82,6 @@ class YourAwesomeApp

[200, {}, ["Oh, you speak #{language}!"]]
end

end
```

Expand Down