Permalink
Browse files

Merge pull request #13871 from kassio/fix-filters-with-classes-docume…

…ntation

Fix documentation of filters api with classes [ci skip]
  • Loading branch information...
2 parents fec1028 + 4256662 commit 6277bd80c904290ca97c5c0380678cd981992d99 @robin850 robin850 committed Jan 29, 2014
Showing with 12 additions and 2 deletions.
  1. +7 −0 activesupport/CHANGELOG.md
  2. +3 −0 guides/source/4_1_release_notes.md
  3. +2 −2 guides/source/action_controller_overview.md
@@ -1,3 +1,10 @@
+* Remove the deprecation about the `#filter` method
+
+ Filter objects should now rely on method corresponding to the filter type
+ (e.g. `#before`)
+
+ *Aaron Patterson*
+
* Add `ActiveSupport::JSON::Encoding.time_precision` as a way to configure the
precision of encoded time values:
@@ -567,6 +567,9 @@ for detailed changes.
* Removed deprecated `assert_present` and `assert_blank` methods, use `assert
object.blank?` and `assert object.present?` instead.
+* Remove deprecated `#filter` method for filter objects, use the corresponding
+ method instead (e.g. `#before` for a before filter).
+
### Deprecations
* Deprecated `Numeric#{ago,until,since,from_now}`, the user is expected to
@@ -709,7 +709,7 @@ class ApplicationController < ActionController::Base
end
class LoginFilter
- def self.filter(controller)
+ def self.before(controller)
unless controller.send(:logged_in?)
controller.flash[:error] = "You must be logged in to access this section"
controller.redirect_to controller.new_login_url
@@ -718,7 +718,7 @@ class LoginFilter
end
```
-Again, this is not an ideal example for this filter, because it's not run in the scope of the controller but gets the controller passed as an argument. The filter class has a class method `filter` which gets run before or after the action, depending on if it's a before or after filter. Classes used as around filters can also use the same `filter` method, which will get run in the same way. The method must `yield` to execute the action. Alternatively, it can have both a `before` and an `after` method that are run before and after the action.
+Again, this is not an ideal example for this filter, because it's not run in the scope of the controller but gets the controller passed as an argument. The filter class must implement a method with the same name as the filter, so for the `before_action` filter the class must implement a `before` method, and so on. The `around` method must `yield` to execute the action.
Request Forgery Protection
--------------------------

0 comments on commit 6277bd8

Please sign in to comment.