Class: Overule::RulesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/overule/rules_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
# File 'app/controllers/overule/rules_controller.rb', line 21

def create
  @rule = Rule.new(rule_params)
  if @rule.save
    redirect_to @rule, notice: "Rule created."
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject



38
39
40
41
# File 'app/controllers/overule/rules_controller.rb', line 38

def destroy
  @rule.destroy
  redirect_to rules_path, notice: "Rule deleted."
end

#editObject



17
18
19
# File 'app/controllers/overule/rules_controller.rb', line 17

def edit
  # Rendered implicitly: the edit view consumes @rule loaded by set_rule.
end

#indexObject



5
6
7
# File 'app/controllers/overule/rules_controller.rb', line 5

def index
  @rules = Rule.order(:name)
end

#newObject



13
14
15
# File 'app/controllers/overule/rules_controller.rb', line 13

def new
  @rule = Rule.new(definition: Rule::BLANK_DEFINITION.deep_dup)
end

#showObject



9
10
11
# File 'app/controllers/overule/rules_controller.rb', line 9

def show
  # Rendered implicitly: the show view consumes @rule loaded by set_rule.
end

#updateObject



30
31
32
33
34
35
36
# File 'app/controllers/overule/rules_controller.rb', line 30

def update
  if @rule.update(rule_params)
    redirect_to @rule, notice: "Rule updated."
  else
    render :edit, status: :unprocessable_entity
  end
end