Class: Super::ApplicationController

Inherits:
ViewController show all
Includes:
ClientError::Handling
Defined in:
app/controllers/super/application_controller.rb

Overview

Provides a default implementation for each of the resourceful actions

Instance Method Summary collapse

Methods inherited from SubstructureController

batch

Instance Method Details

#createvoid

This method returns an undefined value.

Creates a record, or shows the validation errors



53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/super/application_controller.rb', line 53

def create
  @record = build_record
  set_record_attributes

  if save_record
    redirect_to_record
  else
    render_new_as_bad_request
  end
end

#destroyvoid

This method returns an undefined value.

Deletes a record, or shows validation errors



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

def destroy
  @record = load_record

  if destroy_record
    redirect_to_records
  else
    redirect_to_record_with_destroy_failure_message
  end
rescue ActiveRecord::ActiveRecordError => e
  redirect_to_record_with_destroy_failure_message(e)
end

#editvoid

This method returns an undefined value.

Displays a form to allow the user to update an existing record



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

def edit
  @record = load_record
  @form = form_schema
  @view = edit_view
end

#indexvoid

This method returns an undefined value.

Displays a list of records to the user



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/super/application_controller.rb', line 17

def index
  if request.format.ref == :csv && !csv_enabled?
    params_for_rebuilding_url = params.to_unsafe_hash
    params_for_rebuilding_url.delete("format")
    return redirect_to params_for_rebuilding_url
  end

  @records = load_records
  @display = display_schema.apply(action: current_action, format: request.format)
  @view = index_view
  initialize_filter_form
  initialize_sort_form
  @records = apply_queries
end

#newvoid

This method returns an undefined value.

Displays a form to allow the user to create a new record



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

def new
  @record = build_record
  @form = form_schema
  @view = new_view
end

#showvoid

This method returns an undefined value.

Displays a specific record to the user



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

def show
  @record = load_record
  @display = display_schema.apply(action: current_action, format: request.format)
  @view = show_view
end

#updatevoid

This method returns an undefined value.

Updates a record, or shows validation errors



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

def update
  @record = load_record
  set_record_attributes

  if save_record
    redirect_to_record
  else
    render_edit_as_bad_request
  end
end