Sha256: 744e62e2a45fa22f72d6b5f2cf9fec8d1bed293e50b21be3c09405201028a763

Contents?: true

Size: 1.34 KB

Versions: 9

Compression:

Stored size: 1.34 KB

Contents

module ActiveAdmin
  module Views
    module Pages
      class Show < Base

        def config
          active_admin_config.page_configs[:show] || ::ActiveAdmin::PageConfig.new
        end

        def title
          case config[:title]
          when Symbol, Proc
            call_method_or_proc_on(resource, config[:title])
          when String
            config[:title]
          else
            default_title
          end
        end

        def main_content
          if config.block
            # Eval the show config from the controller
            instance_exec resource, &config.block
          else
            default_main_content
          end
        end

        def attributes_table(*args, &block)
          panel(I18n.t('active_admin.details', :model => active_admin_config.resource_name)) do
            attributes_table_for resource, *args, &block
          end
        end

        protected

        def default_title
          "#{active_admin_config.resource_name} ##{resource.id}"
        end

        module DefaultMainContent
          def default_main_content
            attributes_table *default_attribute_table_rows
          end

          def default_attribute_table_rows
            resource.class.columns.collect{|column| column.name.to_sym }
          end
        end

        include DefaultMainContent
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 4 rubygems

Version Path
andrewroth_activeadmin-0.3.4 lib/active_admin/views/pages/show.rb
activeadmin-0.3.4 lib/active_admin/views/pages/show.rb
activeadmin-0.3.3 lib/active_admin/views/pages/show.rb
activeadmin-0.3.2 lib/active_admin/views/pages/show.rb
activeadmin-0.3.1 lib/active_admin/views/pages/show.rb
activeadmin-0.3.0 lib/active_admin/views/pages/show.rb
nsm-activeadmin-0.2.2 lib/active_admin/views/pages/show.rb
saulolso-activeadmin-0.2.2.1 lib/active_admin/views/pages/show.rb
saulolso-activeadmin-0.2.2 lib/active_admin/views/pages/show.rb