Class: ActiveAdmin::ResourceController
- Inherits:
-
BaseController
- Object
- InheritedResources::Base
- BaseController
- ActiveAdmin::ResourceController
- Extended by:
- ResourceClassMethods
- Includes:
- Actions, Callbacks, ActionBuilder, Collection, Decorators, Scoping, Sidebars
- Defined in:
- lib/active_admin/resource_controller.rb,
lib/active_admin/resource_controller/scoping.rb,
lib/active_admin/resource_controller/actions.rb,
lib/active_admin/resource_controller/sidebars.rb,
lib/active_admin/resource_controller/callbacks.rb,
lib/active_admin/resource_controller/decorators.rb,
lib/active_admin/resource_controller/collection.rb,
lib/active_admin/resource_controller/action_builder.rb,
lib/active_admin/resource_controller/resource_class_methods.rb
Overview
All Resources Controller inherits from this controller. It implements actions and helpers for resources.
Defined Under Namespace
Modules: ActionBuilder, Callbacks, Collection, Decorators, ResourceClassMethods, Scoping, Sidebars
Constant Summary
Class Method Summary (collapse)
- + (Object) active_admin_config=(config)
- + (Object) belongs_to
-
+ (Object) inherited(base)
Inherited Resources uses the inherited(base) hook method to add in the Base.resource_class class method.
Instance Method Summary (collapse)
-
- (Object) active_admin_template(template)
protected
Returns the full location to the Active Admin template path.
- - (Object) create(options = {}, &block) (also: #create!)
-
- (Object) csv_filename
protected
Returns a filename for the csv file using the collection_name and current date such as 'my-articles-2011-06-24.csv'.
- - (Object) edit(options = {}, &block) (also: #edit!)
-
- (Object) index(options = {}, &block)
(also: #index!)
Override the InheritedResources actions to use the Active Admin templates.
- - (Object) new(options = {}, &block) (also: #new!)
- - (Object) show(options = {}, &block) (also: #show!)
- - (Object) update(options = {}, &block) (also: #update!)
Methods included from ResourceClassMethods
override_resource_class_methods!
Methods included from Sidebars
#skip_sidebar!, #skip_sidebar?
Methods included from Scoping
#begin_of_association_chain, #method_for_association_chain
Methods included from Decorators
#active_admin_collection, #resource
Methods included from Collection::Pagination
#active_admin_collection, #max_csv_records, #max_per_page, #paginate, #per_page
Methods included from Collection::Scoping
#active_admin_collection, #collection_before_scope, #current_scope, #scope_current_collection
Methods included from ScopeChain
Methods included from Collection::Search
#active_admin_collection, #clean_search_params, #search
Methods included from Collection::Sorting
#active_admin_collection, #sort_order
Methods included from Collection::BaseCollection
#active_admin_collection, #collection, #scoped_collection
Methods included from Callbacks
Methods inherited from BaseController
actions, #only_render_implemented_actions
Methods included from BaseController::Menu
#current_menu, #set_current_tab
Class Method Details
+ (Object) active_admin_config=(config)
30 31 32 33 34 35 36 |
# File 'lib/active_admin/resource_controller.rb', line 30 def active_admin_config=(config) @active_admin_config = config unless config.nil? defaults :resource_class => config.resource_class, :route_prefix => config.route_prefix, :instance_name => config.resource_name.singular end end |
+ (Object) belongs_to
+ (Object) inherited(base)
Inherited Resources uses the inherited(base) hook method to add in the Base.resource_class class method. To override it, we need to install our resource_class method each time we're inherited from.
41 42 43 44 |
# File 'lib/active_admin/resource_controller.rb', line 41 def inherited(base) super(base) base.override_resource_class_methods! end |
Instance Method Details
- (Object) active_admin_template(template) (protected)
Returns the full location to the Active Admin template path
70 71 72 |
# File 'lib/active_admin/resource_controller/actions.rb', line 70 def active_admin_template(template) "active_admin/resource/#{template}" end |
- (Object) create(options = {}, &block) Also known as: create!
47 48 49 50 51 52 |
# File 'lib/active_admin/resource_controller/actions.rb', line 47 def create(={}, &block) super() do |success, failure| block.call(success, failure) if block failure.html { render active_admin_template('new') } end end |
- (Object) csv_filename (protected)
Returns a filename for the csv file using the collection_name and current date such as 'my-articles-2011-06-24.csv'.
76 77 78 |
# File 'lib/active_admin/resource_controller/actions.rb', line 76 def csv_filename "#{resource_collection_name.to_s.gsub('_', '-')}-#{Time.now.strftime("%Y-%m-%d")}.csv" end |
- (Object) edit(options = {}, &block) Also known as: edit!
39 40 41 42 43 44 |
# File 'lib/active_admin/resource_controller/actions.rb', line 39 def edit(={}, &block) super do |format| block.call(format) if block format.html { render active_admin_template('edit') } end end |
- (Object) index(options = {}, &block) 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(={}, &block) super() do |format| block.call(format) if block format.html { render active_admin_template('index') } format.csv do headers['Content-Type'] = 'text/csv; charset=utf-8' headers['Content-Disposition'] = %{attachment; filename="#{csv_filename}"} render active_admin_template('index') end end end |
- (Object) new(options = {}, &block) Also known as: new!
31 32 33 34 35 36 |
# File 'lib/active_admin/resource_controller/actions.rb', line 31 def new(={}, &block) super do |format| block.call(format) if block format.html { render active_admin_template('new') } end end |
- (Object) show(options = {}, &block) Also known as: show!
23 24 25 26 27 28 |
# File 'lib/active_admin/resource_controller/actions.rb', line 23 def show(={}, &block) super do |format| block.call(format) if block format.html { render active_admin_template('show') } end end |
- (Object) update(options = {}, &block) Also known as: update!
55 56 57 58 59 60 |
# File 'lib/active_admin/resource_controller/actions.rb', line 55 def update(={}, &block) super do |success, failure| block.call(success, failure) if block failure.html { render active_admin_template('edit') } end end |