Module: ActiveAction::ActionController::ClassMethods

Defined in:
lib/active_action/action_controller.rb

Instance Method Summary collapse

Instance Method Details

#_active_actionsObject



39
40
41
# File 'lib/active_action/action_controller.rb', line 39

def _active_actions
  @_active_actions ||= []
end

#active_action(action_name, options = {}) ⇒ Object

Rails generates CSRF tokens on a per-form basis. This means things will break when you change the action.

See github.com/rails/rails/pull/22275 for more info.



17
18
19
20
# File 'lib/active_action/action_controller.rb', line 17

def active_action(action_name, options = {})
  protect_from_forgery except: action_name
  add_active_action(action_name, options)
end

#add_active_action(action_name, options = {}) ⇒ Object



22
23
24
25
# File 'lib/active_action/action_controller.rb', line 22

def add_active_action(action_name, options = {})
  options = normalize_active_action_options(action_name, options)
  _active_actions << ActiveAction::Action.new(action_name, options)
end

#normalize_active_action_options(action_name, options) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/active_action/action_controller.rb', line 27

def normalize_active_action_options(action_name, options)
  options[:label] ||= action_name.to_s.titleize
  options[:scopes] ||= []
  options[:scopes] += (Array.wrap(options[:scope]))
  if options[:scopes].empty?
    options[:scopes] << :all
  end
  options[:scopes].map!(&:to_sym)
  options[:path] ||= action_name
  options
end