Sha256: a0d3c6b384a48bd184f596b8e254a8e87f48b4fc8a84432ef5e55a3daf440b3a

Contents?: true

Size: 1.35 KB

Versions: 41

Compression:

Stored size: 1.35 KB

Contents

---
redirect_from: /docs/3-index-pages/index-as-blog.html
---

# Index as Blog

Render your index page as a set of posts. The post has two main options:
title and body.

```ruby
index as: :blog do
  title :my_title # Calls #my_title on each resource
  body  :my_body  # Calls #my_body on each resource
end
```

## Post Title

The title is the content that will be rendered within a link to the
resource. There are two main ways to set the content for the title

First, you can pass in a method to be called on your resource. For example:

```ruby
index as: :blog do
  title :a_method_to_call
end
```

Second, you can pass a block to the tile option which will then be
used as the contents of the title. The resource being rendered
is passed in to the block. For Example:

```ruby
index as: :blog do
  title do |post|
    span post.title,      class: 'title'
    span post.created_at, class: 'created_at'
  end
end
```

## Post Body

The body is rendered underneath the title of each post. The same two
style of options work as the Post Title above.

Call a method on the resource as the body:

```ruby
index as: :blog do
  title :my_title
  body :my_body
end
```

Or, render a block as the body:

```ruby
index as: :blog do
  title :my_title
  body do |post|
    div truncate post.title
    div class: 'meta' do
      span "Post in #{post.categories.join(', ')}"
    end
  end
end
```

Version data entries

41 entries across 41 versions & 4 rubygems

Version Path
activeadmin-2.13.1 docs/3-index-pages/index-as-blog.md
activeadmin-2.13.0 docs/3-index-pages/index-as-blog.md
activeadmin-2.12.0 docs/3-index-pages/index-as-blog.md
activeadmin-2.11.2 docs/3-index-pages/index-as-blog.md
activeadmin-rb-1.6.0 docs/3-index-pages/index-as-blog.md
activeadmin-2.11.1 docs/3-index-pages/index-as-blog.md
activeadmin-2.11.0 docs/3-index-pages/index-as-blog.md
activeadmin-2.10.1 docs/3-index-pages/index-as-blog.md
activeadmin-2.10.0 docs/3-index-pages/index-as-blog.md
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/activeadmin-2.9.0/docs/3-index-pages/index-as-blog.md
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/activeadmin-2.9.0/docs/3-index-pages/index-as-blog.md
activeadmin-rb-1.5.2 docs/3-index-pages/index-as-blog.md
activeadmin-2.9.0 docs/3-index-pages/index-as-blog.md
activeadmin-2.8.1 docs/3-index-pages/index-as-blog.md
activeadmin-2.8.0 docs/3-index-pages/index-as-blog.md
activeadmin-rb-1.5.1 docs/3-index-pages/index-as-blog.md
activeadmin-2.7.0 docs/3-index-pages/index-as-blog.md
activeadmin-2.6.1 docs/3-index-pages/index-as-blog.md
activeadmin-2.6.0 docs/3-index-pages/index-as-blog.md
activeadmin-2.5.0 docs/3-index-pages/index-as-blog.md