Class: ActiveAdmin::ResourceController

Inherits:
InheritedResources::Base
  • Object
show all
Includes:
Actions, ActionItems, Callbacks, ActionBuilder, Collection, Filters, Form, Menu, PageConfigurations, Scoping, Sidebars
Defined in:
lib/active_admin/resource_controller.rb,
lib/active_admin/resource_controller/form.rb,
lib/active_admin/resource_controller/menu.rb,
lib/active_admin/resource_controller/actions.rb,
lib/active_admin/resource_controller/filters.rb,
lib/active_admin/resource_controller/scoping.rb,
lib/active_admin/resource_controller/sidebars.rb,
lib/active_admin/resource_controller/callbacks.rb,
lib/active_admin/resource_controller/collection.rb,
lib/active_admin/resource_controller/action_builder.rb,
lib/active_admin/resource_controller/page_configurations.rb

Direct Known Subclasses

Dashboards::DashboardController

Defined Under Namespace

Modules: ActionBuilder, Callbacks, Collection, Filters, Form, Menu, PageConfigurations, Scoping, Sidebars

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.active_admin_configObject

Reference to the Resource object which initialized this controller



42
43
44
# File 'lib/active_admin/resource_controller.rb', line 42

def active_admin_config
  @active_admin_config
end

Instance Method Details

#create(options = {}, &block) ⇒ Object Also known as: create!



47
48
49
50
51
52
# File 'lib/active_admin/resource_controller/actions.rb', line 47

def create(options={}, &block)
  super(options) do |success, failure|
    block.call(success, failure) if block
    failure.html { render active_admin_template('new.html.arb') }
  end
end

#edit(options = {}, &block) ⇒ Object Also known as: edit!



39
40
41
42
43
44
# File 'lib/active_admin/resource_controller/actions.rb', line 39

def edit(options={}, &block)
  super do |format|
    block.call(format) if block
    format.html { render active_admin_template('edit.html.arb') }
  end
end

#index(options = {}, &block) ⇒ Object Also known as: index!

Override the InheritedResources actions to use the Active Admin templates.

We ensure that the functionality provided by Inherited Resources is still available within any ResourceController



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/active_admin/resource_controller/actions.rb', line 10

def index(options={}, &block)
  super(options) do |format|
    block.call(format) if block
    format.html { render active_admin_template('index.html.arb') }
    format.csv do
      headers['Content-Type'] = 'text/csv; charset=utf-8'
      headers['Content-Disposition'] = %{attachment; filename="#{csv_filename}"}
      render active_admin_template('index.csv.erb')
    end
  end
end

#new(options = {}, &block) ⇒ Object Also known as: new!



31
32
33
34
35
36
# File 'lib/active_admin/resource_controller/actions.rb', line 31

def new(options={}, &block)
  super do |format|
    block.call(format) if block
    format.html { render active_admin_template('new.html.arb') }
  end
end

#show(options = {}, &block) ⇒ Object Also known as: show!



23
24
25
26
27
28
# File 'lib/active_admin/resource_controller/actions.rb', line 23

def show(options={}, &block)
  super do |format|
    block.call(format) if block
    format.html { render active_admin_template('show.html.arb') }
  end
end

#update(options = {}, &block) ⇒ Object Also known as: update!



55
56
57
58
59
60
# File 'lib/active_admin/resource_controller/actions.rb', line 55

def update(options={}, &block)
  super do |success, failure|
    block.call(success, failure) if block
    failure.html { render active_admin_template('edit.html.arb') }
  end
end