class ActiveAdmin::Views::IndexAsBlog


“‘
end
end
end
span “Post in #{post.categories.join(’, ‘)}”
div class: ’meta’ do
div truncate post.title
body do |post|
title :my_title
index as: :blog do
“‘ruby
Or, render a block as the body:
“`
end
body :my_body
title :my_title
index as: :blog do
“`ruby
Call a method on the resource as the body:
style of options work as the Post Title above.
The body is rendered underneath the title of each post. The same two
## Post Body
“`
end
end
span post.created_at, class: ’created_at’
span post.title, class: ‘title’
title do |post|
index as: :blog do
“‘ruby
is passed in to the block. For Example:
used as the contents of the title. The resource being rendered
Second, you can pass a block to the tile option which will then be
“`
end
title :a_method_to_call
index as: :blog do
“`ruby
First, you can pass in a method to be called on your resource. For example:
resource. There are two main ways to set the content for the title
The title is the content that will be rendered within a link to the
## Post Title
“`
end
body :my_body # Calls #my_body on each resource
title :my_title # Calls #my_title on each resource
index as: :blog do
“`ruby
title and body.
Render your index page as a set of posts. The post has two main options:
# Index as Blog

def self.index_name

def self.index_name
  "blog"
end

def body(method = nil, &block)


Setter method for the configuration of the body
def body(method = nil, &block)
  if block_given? || method
    @body = block_given? ? block : method
  end
  @body
end

def build(page_presenter, collection)

def build(page_presenter, collection)
  @page_presenter = page_presenter
  @collection = collection
  # Call the block passed in. This will set the
  # title and body methods
  instance_exec &page_presenter.block if page_presenter.block
  add_class "index"
  build_posts
end

def build_body(post)

def build_body(post)
  if @body
    div class: "content" do
      render_method_on_post_or_call_proc post, @body
    end
  end
end

def build_post(post)

def build_post(post)
  div for: post do
    resource_selection_cell(post) if active_admin_config.batch_actions.any?
    build_title(post)
    build_body(post)
  end
end

def build_posts

def build_posts
  resource_selection_toggle_panel if active_admin_config.batch_actions.any?
  @collection.each do |post|
    build_post(post)
  end
end

def build_title(post)

def build_title(post)
  if @title
    h3 do
      a(href: resource_path(post)) do
        render_method_on_post_or_call_proc post, @title
      end
    end
  else
    h3 do
      auto_link(post)
    end
  end
end

def render_method_on_post_or_call_proc(post, proc)

def render_method_on_post_or_call_proc(post, proc)
  case proc
  when String, Symbol
    post.public_send proc
  else
    instance_exec post, &proc
  end
end

def title(method = nil, &block)

Setter method for the configuration of the title
def title(method = nil, &block)
  if block_given? || method
    @title = block_given? ? block : method
  end
  @title
end