Class: PyrRules::ActionsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/pyr_rules/actions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



3
4
5
6
7
8
# File 'app/controllers/pyr_rules/actions_controller.rb', line 3

def create
  @rule = PyrRules::Rule.find(params[:rule_id])
  @action = @rule.actions.create!(params[:pyr_rules_action])

  redirect_to (params[:event_id].presence ? pyr_rules_event_rule_url(@rule, event_id: params[:event_id]) : pyr_rules_rule_url(@rule)), :notice => "Action created!"
end

#destroyObject



10
11
12
13
14
15
# File 'app/controllers/pyr_rules/actions_controller.rb', line 10

def destroy
  @rule = PyrRules::Rule.find(params[:rule_id])
  @rule.actions.delete(@rule.actions.find(params[:id]))

  redirect_to (params[:event_id].presence ? pyr_rules_event_rule_url(@rule, event_id: params[:event_id]) : pyr_rules_rule_url(@rule)), :notice => "Action deleted!"
end

#indexObject



17
18
19
20
# File 'app/controllers/pyr_rules/actions_controller.rb', line 17

def index
  @actions_config = PyrRules::ActionHandler.actions_config 
  @actions = @actions_config.map{|type,needs| a= PyrRules::Action.new;a.type=type;a}
end