mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #8455 from frodsan/actionize
Actionize: Use `_action` callbacks in documentation and code
This commit is contained in:
commit
9cb91f9329
14 changed files with 28 additions and 28 deletions
|
@ -91,7 +91,7 @@ module AbstractController
|
|||
# :call-seq: prepend_before_action(names, block)
|
||||
#
|
||||
# Prepend a callback before actions. See _insert_callbacks for parameter details.
|
||||
# Aliased as prepend_before_action.
|
||||
# Aliased as prepend_before_filter.
|
||||
|
||||
##
|
||||
# :method: skip_before_action
|
||||
|
|
|
@ -32,14 +32,14 @@ module ActionController
|
|||
# ==== Options
|
||||
# * <tt>host</tt> - Redirect to a different host name
|
||||
# * <tt>only</tt> - The callback should be run only for this action
|
||||
# * <tt>except</tt> - The callback should be run for all actions except this action
|
||||
# * <tt>except</tt> - The callback should be run for all actions except this action
|
||||
# * <tt>if</tt> - A symbol naming an instance method or a proc; the callback
|
||||
# will be called only when it returns a true value.
|
||||
# * <tt>unless</tt> - A symbol naming an instance method or a proc; the callback
|
||||
# will be called only when it returns a false value.
|
||||
def force_ssl(options = {})
|
||||
host = options.delete(:host)
|
||||
before_filter(options) do
|
||||
before_action(options) do
|
||||
force_ssl_redirect(host)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,7 +25,7 @@ module ActionController
|
|||
# the regular HTML interface is protected by a session approach:
|
||||
#
|
||||
# class ApplicationController < ActionController::Base
|
||||
# before_filter :set_account, :authenticate
|
||||
# before_action :set_account, :authenticate
|
||||
#
|
||||
# protected
|
||||
# def set_account
|
||||
|
@ -68,7 +68,7 @@ module ActionController
|
|||
|
||||
module ClassMethods
|
||||
def http_basic_authenticate_with(options = {})
|
||||
before_filter(options.except(:name, :password, :realm)) do
|
||||
before_action(options.except(:name, :password, :realm)) do
|
||||
authenticate_or_request_with_http_basic(options[:realm] || "Application") do |name, password|
|
||||
name == options[:name] && password == options[:password]
|
||||
end
|
||||
|
@ -124,7 +124,7 @@ module ActionController
|
|||
# USERS = {"dhh" => "secret", #plain text password
|
||||
# "dap" => Digest::MD5.hexdigest(["dap",REALM,"secret"].join(":"))} #ha1 digest password
|
||||
#
|
||||
# before_filter :authenticate, except: [:index]
|
||||
# before_action :authenticate, except: [:index]
|
||||
#
|
||||
# def index
|
||||
# render text: "Everyone can see me!"
|
||||
|
@ -317,7 +317,7 @@ module ActionController
|
|||
# class PostsController < ApplicationController
|
||||
# TOKEN = "secret"
|
||||
#
|
||||
# before_filter :authenticate, except: [ :index ]
|
||||
# before_action :authenticate, except: [ :index ]
|
||||
#
|
||||
# def index
|
||||
# render text: "Everyone can see me!"
|
||||
|
@ -340,7 +340,7 @@ module ActionController
|
|||
# the regular HTML interface is protected by a session approach:
|
||||
#
|
||||
# class ApplicationController < ActionController::Base
|
||||
# before_filter :set_account, :authenticate
|
||||
# before_action :set_account, :authenticate
|
||||
#
|
||||
# protected
|
||||
# def set_account
|
||||
|
|
|
@ -2,9 +2,9 @@ require 'abstract_unit'
|
|||
|
||||
class HttpBasicAuthenticationTest < ActionController::TestCase
|
||||
class DummyController < ActionController::Base
|
||||
before_filter :authenticate, :only => :index
|
||||
before_filter :authenticate_with_request, :only => :display
|
||||
before_filter :authenticate_long_credentials, :only => :show
|
||||
before_action :authenticate, only: :index
|
||||
before_action :authenticate_with_request, only: :display
|
||||
before_action :authenticate_long_credentials, only: :show
|
||||
|
||||
http_basic_authenticate_with :name => "David", :password => "Goliath", :only => :search
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ require 'active_support/key_generator'
|
|||
|
||||
class HttpDigestAuthenticationTest < ActionController::TestCase
|
||||
class DummyDigestController < ActionController::Base
|
||||
before_filter :authenticate, :only => :index
|
||||
before_filter :authenticate_with_request, :only => :display
|
||||
before_action :authenticate, only: :index
|
||||
before_action :authenticate_with_request, only: :display
|
||||
|
||||
USERS = { 'lifo' => 'world', 'pretty' => 'please',
|
||||
'dhh' => ::Digest::MD5::hexdigest(["dhh","SuperSecret","secret"].join(":"))}
|
||||
|
|
|
@ -2,9 +2,9 @@ require 'abstract_unit'
|
|||
|
||||
class HttpTokenAuthenticationTest < ActionController::TestCase
|
||||
class DummyController < ActionController::Base
|
||||
before_filter :authenticate, :only => :index
|
||||
before_filter :authenticate_with_request, :only => :display
|
||||
before_filter :authenticate_long_credentials, :only => :show
|
||||
before_action :authenticate, only: :index
|
||||
before_action :authenticate_with_request, only: :display
|
||||
before_action :authenticate_long_credentials, only: :show
|
||||
|
||||
def index
|
||||
render :text => "Hello Secret"
|
||||
|
|
|
@ -13,7 +13,7 @@ module Another
|
|||
head :status => 406
|
||||
end
|
||||
|
||||
before_filter :redirector, :only => :never_executed
|
||||
before_action :redirector, only: :never_executed
|
||||
|
||||
def never_executed
|
||||
end
|
||||
|
|
|
@ -1139,7 +1139,7 @@ end
|
|||
|
||||
# For testing layouts which are set automatically
|
||||
class PostController < AbstractPostController
|
||||
around_filter :with_iphone
|
||||
around_action :with_iphone
|
||||
|
||||
def index
|
||||
respond_to(:html, :iphone, :js)
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'abstract_unit'
|
|||
# Tests the controller dispatching happy path
|
||||
module Dispatching
|
||||
class SimpleController < ActionController::Base
|
||||
before_filter :authenticate
|
||||
before_action :authenticate
|
||||
|
||||
def index
|
||||
render :text => "success"
|
||||
|
|
|
@ -14,7 +14,7 @@ module RenderContext
|
|||
include ActionView::Context
|
||||
|
||||
# 2) Call _prepare_context that will do the required initialization
|
||||
before_filter :_prepare_context
|
||||
before_action :_prepare_context
|
||||
|
||||
def hello_world
|
||||
@value = "Hello"
|
||||
|
|
|
@ -37,7 +37,7 @@ end
|
|||
class TestController < ActionController::Base
|
||||
protect_from_forgery
|
||||
|
||||
before_filter :set_variable_for_layout
|
||||
before_action :set_variable_for_layout
|
||||
|
||||
class LabellingFormBuilder < ActionView::Helpers::FormBuilder
|
||||
end
|
||||
|
@ -137,7 +137,7 @@ class TestController < ActionController::Base
|
|||
def conditional_hello_with_bangs
|
||||
render :action => 'hello_world'
|
||||
end
|
||||
before_filter :handle_last_modified_and_etags, :only=>:conditional_hello_with_bangs
|
||||
before_action :handle_last_modified_and_etags, :only=>:conditional_hello_with_bangs
|
||||
|
||||
def handle_last_modified_and_etags
|
||||
fresh_when(:last_modified => Time.now.utc.beginning_of_day, :etag => [ :foo, 123 ])
|
||||
|
@ -710,7 +710,7 @@ class TestController < ActionController::Base
|
|||
render :action => "calling_partial_with_layout", :layout => "layouts/partial_with_layout"
|
||||
end
|
||||
|
||||
before_filter :only => :render_with_filters do
|
||||
before_action only: :render_with_filters do
|
||||
request.format = :xml
|
||||
end
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ class RescueController < ActionController::Base
|
|||
render :text => 'io error'
|
||||
end
|
||||
|
||||
before_filter(:only => :before_filter_raises) { raise 'umm nice' }
|
||||
before_action(only: :before_filter_raises) { raise 'umm nice' }
|
||||
|
||||
def before_filter_raises
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ module ShowExceptions
|
|||
use ActionDispatch::ShowExceptions, ActionDispatch::PublicExceptions.new("#{FIXTURE_LOAD_PATH}/public")
|
||||
use ActionDispatch::DebugExceptions
|
||||
|
||||
before_filter :only => :another_boom do
|
||||
before_action only: :another_boom do
|
||||
request.env["action_dispatch.show_detailed_exceptions"] = true
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ class ViewLoadPathsTest < ActionController::TestCase
|
|||
class TestController < ActionController::Base
|
||||
def self.controller_path() "test" end
|
||||
|
||||
before_filter :add_view_path, :only => :hello_world_at_request_time
|
||||
before_action :add_view_path, only: :hello_world_at_request_time
|
||||
|
||||
def hello_world() end
|
||||
def hello_world_at_request_time() render(:action => 'hello_world') end
|
||||
|
|
Loading…
Reference in a new issue