Skip to content

Commit 08be240

Browse files
bureniNecas
authored andcommitted
Replace #before_filter with #before_action
1 parent 2a228ef commit 08be240

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

README.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ default_version
531531
validate
532532
Parameters validation is turned off when set to false. When set to
533533
``:explicitly``, you must invoke parameter validation yourself by calling
534-
controller method ``apipie_validations`` (typically in a before_filter).
534+
controller method ``apipie_validations`` (typically in a before_action).
535535
When set to ``:implicitly`` (or just true), your controller's action
536536
methods are wrapped with generated methods which call ``apipie_validations``,
537537
and then call the action method. (``:implicitly`` by default)
@@ -729,17 +729,17 @@ is raised and can be rescued and processed. It contains a description
729729
of the parameter value expectations. Validations can be turned off
730730
in the configuration file.
731731

732-
Parameter validation normally happens after before_filters, just before
732+
Parameter validation normally happens after before_actions, just before
733733
your controller method is invoked. If you prefer to control when parameter
734734
validation occurs, set the configuration parameter ``validate`` to ``:explicitly``.
735735
You must then call the ``apipie_validations`` method yourself, e.g.:
736736

737737
.. code:: ruby
738738
739-
before_filter: :apipie_validations
739+
before_action: :apipie_validations
740740
741-
This is useful if you have before_filters which use parameter values: just add them
742-
after the ``apipie_validations`` before_filter.
741+
This is useful if you have before_actions which use parameter values: just add them
742+
after the ``apipie_validations`` before_action.
743743

744744
TypeValidator
745745
-------------

app/controllers/apipie/apipies_controller.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ class ApipiesController < ActionController::Base
55

66
layout Apipie.configuration.layout
77

8-
around_filter :set_script_name
9-
before_filter :authenticate
8+
around_action :set_script_name
9+
before_action :authenticate
1010

1111
def authenticate
1212
if Apipie.configuration.authenticate

lib/apipie/extractor.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
class Apipie::Railtie
1010
initializer 'apipie.extractor' do |app|
1111
ActiveSupport.on_load :action_controller do
12-
create_filter_method = respond_to?(:before_action) ? :before_action : :before_filter
13-
send(create_filter_method) do |controller|
12+
before_action do |controller|
1413
if Apipie.configuration.record
1514
Apipie::Extractor.call_recorder.analyse_controller(controller)
1615
end

spec/dummy/app/controllers/application_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class ApplicationController < ActionController::Base
2-
before_filter :run_validations
2+
before_action :run_validations
33

44
resource_description do
55
param :oauth, String, :desc => "Authorization", :required => false

0 commit comments

Comments
 (0)