Sha256: 1bcdef5dea1c74668a6b3a0866eac09c7f91d1b586842f016f67a0c158b2e61a
Contents?: true
Size: 1.82 KB
Versions: 2
Compression:
Stored size: 1.82 KB
Contents
module ActiveAdmin module Pages class Index < Base # Default Index config styles. Each of these are what # actually gets rendered in the main content and configured # through the :as option when configuring your index autoload :Table, 'active_admin/pages/index/table' autoload :Blog, 'active_admin/pages/index/blog' autoload :Thumbnails, 'active_admin/pages/index/thumbnails' def title active_admin_config.plural_resource_name end def config index_config || default_index_config end # Render's the index configuration that was set in the # controller. Defaults to rendering the ActiveAdmin::Pages::Index::Table def main_content renderer_class = find_index_renderer_class(config[:as]) renderer_class.new(self).to_html(config, collection) end private # Creates a default configuration for the resource class. This is a table # with each column displayed as well as all the default actions def default_index_config @default_index_config ||= ::ActiveAdmin::PageConfig.new(:as => :table) do |display| display.id resource_class.content_columns.each do |column| display.column column.name.to_sym end display.default_actions end end # Returns the actual class for renderering the main content on the index # page. To set this, use the :as option in the page_config block. def find_index_renderer_class(symbol_or_class) case symbol_or_class when Symbol ::ActiveAdmin::Pages::Index.const_get(symbol_or_class.to_s.camelcase) when Class symbol_or_class else raise ArgumentError, "'as' requires a class or a symbol" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activeadmin-0.1.1 | lib/active_admin/pages/index.rb |
activeadmin-0.1.0 | lib/active_admin/pages/index.rb |