Class: ActiveAdmin::Page
- Inherits:
-
Object
- Object
- ActiveAdmin::Page
- Includes:
- Base, Resource::ActionItems, Resource::Controllers, Resource::Menu, Resource::Naming, Resource::PagePresenters, Resource::Routes, Resource::Sidebars
- Defined in:
- lib/active_admin/page.rb
Overview
Page is the primary data storage for page configuration in Active Admin
When you register a page (ActiveAdmin.register_page “Status”) you are actually creating a new Page instance within the given Namespace.
The instance of the current page is available in PageController and views by calling the #active_admin_config method.
Defined Under Namespace
Modules: Base
Instance Attribute Summary collapse
-
#breadcrumb ⇒ Object
Set breadcrumb builder.
-
#name ⇒ Object
readonly
The name of the page.
-
#namespace ⇒ Object
readonly
The namespace this config belongs to.
-
#page_actions ⇒ Object
readonly
An array of custom actions defined for this page.
Attributes included from Resource::Menu
Instance Method Summary collapse
- #add_default_action_items ⇒ Object
- #add_default_sidebar_sections ⇒ Object
- #add_page_route(name, options) ⇒ Object
- #belongs_to(target, options = {}) ⇒ Object
-
#belongs_to? ⇒ Boolean
Do we belong to another resource?.
- #belongs_to_config ⇒ Object
- #camelized_resource_name ⇒ Object
-
#clear_page_actions! ⇒ Object
Clears all the custom actions this page knows about.
- #controller_name ⇒ Object
- #default_menu_options ⇒ Object
- #namespace_name ⇒ Object
- #order_clause ⇒ Object
-
#plural_resource_label ⇒ Object
label is singular.
- #resource_name ⇒ Object
-
#route_uncountable? ⇒ Boolean
Override from ‘ActiveAdmin::Resource::Controllers`.
- #underscored_resource_name ⇒ Object
Methods included from Resource::Routes
#route_batch_action_path, #route_builder, #route_collection_path, #route_edit_instance_path, #route_instance_path, #route_prefix
Methods included from Resource::Naming
Methods included from Resource::Menu
#add_to_menu, #include_in_menu?, #menu_item_options, #menu_item_options=, #navigation_menu, #navigation_menu_name, #navigation_menu_name=
Methods included from Resource::ActionItems
#action_items, #action_items?, #action_items_for, #add_action_item, #clear_action_items!, #initialize, #remove_action_item
Methods included from Resource::Sidebars
#add_sidebar_section, #clear_sidebar_sections!, #sidebar_sections, #sidebar_sections?, #sidebar_sections_for
Methods included from Resource::PagePresenters
#default_index_class, #find_index_class, #get_page_presenter, #page_presenters, #set_index_presenter, #set_page_options, #set_page_presenter
Methods included from Resource::Controllers
Methods included from Base
Instance Attribute Details
#breadcrumb ⇒ Object
Set breadcrumb builder
25 26 27 |
# File 'lib/active_admin/page.rb', line 25 def @breadcrumb end |
#name ⇒ Object (readonly)
The name of the page
16 17 18 |
# File 'lib/active_admin/page.rb', line 16 def name @name end |
#namespace ⇒ Object (readonly)
The namespace this config belongs to
13 14 15 |
# File 'lib/active_admin/page.rb', line 13 def namespace @namespace end |
#page_actions ⇒ Object (readonly)
An array of custom actions defined for this page
19 20 21 |
# File 'lib/active_admin/page.rb', line 19 def page_actions @page_actions end |
Instance Method Details
#add_default_action_items ⇒ Object
79 80 |
# File 'lib/active_admin/page.rb', line 79 def add_default_action_items end |
#add_default_sidebar_sections ⇒ Object
82 83 |
# File 'lib/active_admin/page.rb', line 82 def end |
#add_page_route(name, options) ⇒ Object
20 21 22 |
# File 'lib/active_admin/page.rb', line 20 def add_page_route(name, ) page_actions << ControllerAction.new(name, ) end |
#belongs_to(target, options = {}) ⇒ Object
90 91 92 93 94 |
# File 'lib/active_admin/page.rb', line 90 def belongs_to(target, = {}) @belongs_to = Resource::BelongsTo.new(self, target, ) self. = target unless @belongs_to.optional? controller.send :belongs_to, target, .dup end |
#belongs_to? ⇒ Boolean
Do we belong to another resource?
101 102 103 |
# File 'lib/active_admin/page.rb', line 101 def belongs_to? !!belongs_to_config end |
#belongs_to_config ⇒ Object
96 97 98 |
# File 'lib/active_admin/page.rb', line 96 def belongs_to_config @belongs_to end |
#camelized_resource_name ⇒ Object
58 59 60 |
# File 'lib/active_admin/page.rb', line 58 def camelized_resource_name underscored_resource_name.camelize end |
#clear_page_actions! ⇒ Object
Clears all the custom actions this page knows about
86 87 88 |
# File 'lib/active_admin/page.rb', line 86 def clear_page_actions! @page_actions = [] end |
#controller_name ⇒ Object
70 71 72 |
# File 'lib/active_admin/page.rb', line 70 def controller_name [namespace.module_name, camelized_resource_name + "Controller"].compact.join('::') end |
#default_menu_options ⇒ Object
66 67 68 |
# File 'lib/active_admin/page.rb', line 66 def super.merge(id: resource_name) end |
#namespace_name ⇒ Object
62 63 64 |
# File 'lib/active_admin/page.rb', line 62 def namespace_name namespace.name.to_s end |
#order_clause ⇒ Object
109 110 111 |
# File 'lib/active_admin/page.rb', line 109 def order_clause @order_clause || namespace.order_clause end |
#plural_resource_label ⇒ Object
label is singular
46 47 48 |
# File 'lib/active_admin/page.rb', line 46 def plural_resource_label name end |
#resource_name ⇒ Object
50 51 52 |
# File 'lib/active_admin/page.rb', line 50 def resource_name @resource_name ||= Resource::Name.new(nil, name) end |
#route_uncountable? ⇒ Boolean
Override from ‘ActiveAdmin::Resource::Controllers`
75 76 77 |
# File 'lib/active_admin/page.rb', line 75 def route_uncountable? false end |
#underscored_resource_name ⇒ Object
54 55 56 |
# File 'lib/active_admin/page.rb', line 54 def underscored_resource_name resource_name.to_s.parameterize.underscore end |