Class: ActiveAdmin::Views::IndexAsBlog

Inherits:
Component show all
Defined in:
lib/active_admin/views/index_as_blog.rb

Instance Method Summary collapse

Methods inherited from Component

#initialize, #tag_name

Constructor Details

This class inherits a constructor from ActiveAdmin::Component

Instance Method Details

#body(method = nil, &block) ⇒ Object

Setter method for the configuration of the body

index :as => :blog do
  title :my_title

  body :a_method_to_call #=> Calls #a_method_to_call on the resource

  # OR

  title do |post|
    post.a_method_to_call
  end
end


47
48
49
50
51
52
# File 'lib/active_admin/views/index_as_blog.rb', line 47

def body(method = nil, &block)
  if block_given? || method
    @body = block_given? ? block : method
  end
  @body
end

#build(page_config, collection) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/active_admin/views/index_as_blog.rb', line 5

def build(page_config, collection)
  @page_config = page_config
  @collection = collection

  # Call the block passed in. This will set the 
  # title and body methods
  instance_eval &page_config.block if page_config.block

  build_posts
end

#title(method = nil, &block) ⇒ Object

Setter method for the configuration of the title

index :as => :blog do
  title :a_method_to_call #=> Calls #a_method_to_call on the resource

  # OR

  title do |post|
    post.a_method_to_call
  end
end


27
28
29
30
31
32
# File 'lib/active_admin/views/index_as_blog.rb', line 27

def title(method = nil, &block)
  if block_given? || method
    @title = block_given? ? block : method
  end
  @title
end