Class: Super::ApplicationController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/super/application_controller.rb

Overview

Provides a default implementation for each of the resourceful actions

Instance Method Summary collapse

Instance Method Details

#createObject



55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/controllers/super/application_controller.rb', line 55

def create
  @super_action = controls.create
  @super_action.steps.each do |step|
    instance_exec(&step)
  end

  if @resource.save
    redirect_to polymorphic_path(Super.configuration.path_parts(@resource))
  else
    render :new, status: :bad_request
  end
end

#destroyObject



88
89
90
91
92
93
94
95
96
97
98
99
# File 'app/controllers/super/application_controller.rb', line 88

def destroy
  @super_action = controls.destroy
  @super_action.steps.each do |step|
    instance_exec(&step)
  end

  if @resource.destroy
    redirect_to polymorphic_path(Super.configuration.path_parts(controls.model))
  else
    redirect_to polymorphic_path(Super.configuration.path_parts(@resource))
  end
end

#editObject



68
69
70
71
72
73
# File 'app/controllers/super/application_controller.rb', line 68

def edit
  @super_action = controls.edit
  @super_action.steps.each do |step|
    instance_exec(&step)
  end
end

#indexObject



34
35
36
37
38
39
# File 'app/controllers/super/application_controller.rb', line 34

def index
  @super_action = controls.index
  @super_action.steps.each do |step|
    instance_exec(&step)
  end
end

#newObject



48
49
50
51
52
53
# File 'app/controllers/super/application_controller.rb', line 48

def new
  @super_action = controls.new
  @super_action.steps.each do |step|
    instance_exec(&step)
  end
end

#showObject



41
42
43
44
45
46
# File 'app/controllers/super/application_controller.rb', line 41

def show
  @super_action = controls.show
  @super_action.steps.each do |step|
    instance_exec(&step)
  end
end

#updateObject



75
76
77
78
79
80
81
82
83
84
85
86
# File 'app/controllers/super/application_controller.rb', line 75

def update
  @super_action = controls.update
  @super_action.steps.each do |step|
    instance_exec(&step)
  end

  if @resource.update(update_permitted_params)
    redirect_to polymorphic_path(Super.configuration.path_parts(@resource))
  else
    render :edit, status: :bad_request
  end
end