Class: Super::ApplicationController

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

Overview

Provides a default implementation for each of the resourceful actions

Instance Method Summary collapse

Methods included from InlineCallback

#with_inline_callbacks

Instance Method Details

#createObject



43
44
45
46
47
48
49
50
51
# File 'app/controllers/super/application_controller.rb', line 43

def create
  @resource = controls.scope(action: action_inquirer).build(create_permitted_params)

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

#destroyObject



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

def destroy
  @resource = controls.scope(action: action_inquirer).find(params[:id])
  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



57
58
59
# File 'app/controllers/super/application_controller.rb', line 57

def edit
  @resource = controls.scope(action: action_inquirer).find(params[:id])
end

#indexObject



37
38
39
40
41
# File 'app/controllers/super/application_controller.rb', line 37

def index
  with_inline_callbacks do
    @resources = controls.scope(action: action_inquirer)
  end
end

#newObject



53
54
55
# File 'app/controllers/super/application_controller.rb', line 53

def new
  @resource = controls.scope(action: action_inquirer).build
end

#showObject



61
62
63
# File 'app/controllers/super/application_controller.rb', line 61

def show
  @resource = controls.scope(action: action_inquirer).find(params[:id])
end

#updateObject



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

def update
  @resource = controls.scope(action: action_inquirer).find(params[:id])

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