Class: Super::ApplicationController

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

Direct Known Subclasses

AdminController

Instance Method Summary collapse

Methods included from InlineCallback

#with_inline_callbacks

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
# File 'app/controllers/super/application_controller.rb', line 16

def create
  @resource = controls.create_scope.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



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

def destroy
  @resource = controls.destroy_scope.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



30
31
32
# File 'app/controllers/super/application_controller.rb', line 30

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

#indexObject



10
11
12
13
14
# File 'app/controllers/super/application_controller.rb', line 10

def index
  with_inline_callbacks do
    @resources = controls.index_scope
  end
end

#newObject



26
27
28
# File 'app/controllers/super/application_controller.rb', line 26

def new
  @resource = controls.new_scope.build
end

#showObject



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

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

#updateObject



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

def update
  @resource = controls.update_scope.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