Sha256: a3310935e383a31515a761927696ee7663af3b52ef01d8b97750eef2a27d730c

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

module ActiveAdmin
  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_eval &config.block
        else
          default_main_content
        end
      end

      protected

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

      def default_main_content
        table_options = {
          :border => 0, 
          :cellpadding => 0, 
          :cellspacing => 0,
          :id => "#{resource_class.name.underscore}_attributes",
          :class => "resource_attributes"
        }        
        content_tag :table, table_options do
          show_view_columns.collect do |attr|
            content_tag :tr do
              content_tag(:th, attr.to_s.titlecase) + content_tag(:td, resource.send(attr))
            end
          end.join
        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/show.rb
activeadmin-0.1.0 lib/active_admin/pages/show.rb