Class: Chatty::ActiveAdminIntegrator

Inherits:
Object
  • Object
show all
Defined in:
lib/chatty/active_admin_integrator.rb

Class Method Summary collapse

Class Method Details

.integrate!Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/chatty/active_admin_integrator.rb', line 2

def self.integrate!
  ActiveAdmin.register Chatty::Chat do
    index do
      selectable_column
      id_column
      column :user
      column :resource
      column :state
      column :created_at
      actions
    end

    show do
      attributes_table do
        row :id
        row :user
        row :resource
        row :state
        row :created_at
        row :updated_at
      end

      panel Chatty::Message.model_name.human(count: 2) do
        table do
          thead do
            tr do
              th Chatty::Message.human_attribute_name(:id)
              th Chatty::Message.human_attribute_name(:user)
              th Chatty::Message.human_attribute_name(:message)
              th Chatty::Message.human_attribute_name(:created_at)
            end
          end
          tbody do
            resource.messages.each do |message|
              tr do
                td message.id
                td message.user.name
                td message.message
                td message.created_at
              end
            end
          end
        end
      end

      active_admin_comments
    end
  end
end