@@ -59,32 +59,34 @@ If all you need to do is change the columns which get displayed, you can do so b
59
59
them to the columns method:
60
60
61
61
ActiveAdmin.register Post do
62
-
63
- index do |display|
64
- display.columns :title, :comments_count, :created_at
62
+
63
+ index do
64
+ column :title
65
+ column :comments_count
66
+ column :created_at
65
67
end
66
68
67
69
end
68
70
69
71
Or you can pass them in individually:
70
72
71
73
ActiveAdmin.register Post do
72
-
73
- index do |display|
74
+
75
+ index do
74
76
75
77
# This will title the column 'Title' and call the #title method on each object
76
- display. column :title
78
+ column :title
77
79
78
80
# This will title the column 'How many comments?' and call the #comments_count method on each object
79
- display. column 'How many comments?', :comments_count
81
+ column 'How many comments?', :comments_count
80
82
81
83
# You can add methods to the table builder which builds common things (ie: selectable checkboxes)
82
- display. default_actions
84
+ default_actions
83
85
84
86
end
85
87
86
88
end
87
-
89
+
88
90
89
91
==== Advanced Columns
90
92
@@ -94,11 +96,11 @@ example, say we wanted a colum called Title which holds a link to the posts admi
94
96
You can pass a block to a column which will then be rendered within the context of the view
95
97
for each of the objects in the collection.
96
98
97
-
99
+
98
100
ActiveAdmin.register Post do
99
-
100
- index do |display|
101
- display. column("Title"){|post| link_to post.title, admin_post_path(post) }
101
+
102
+ index do
103
+ column("Title"){|post| link_to post.title, admin_post_path(post) }
102
104
end
103
105
104
106
end
@@ -110,20 +112,20 @@ the block as an argument.
110
112
==== Sorting
111
113
112
114
The index views in Active Admin include sorting by default.
113
-
115
+
114
116
ActiveAdmin.register Post do
115
-
116
- index do |display|
117
+
118
+ index do
117
119
118
120
# A column created by a method call assumes its sortable
119
- display. column :id
121
+ column :id
120
122
121
123
# If a column is defined using a block, you must pass the key to turn on sorting. The key
122
124
# is the attribute which gets used to sort objects using Active Record.
123
- display. column("Title", :sortable => :title){|post| link_to post.title, admin_post_path(post) }
125
+ column("Title", :sortable => :title){|post| link_to post.title, admin_post_path(post) }
124
126
125
127
# Turn off sorting by passing false
126
- display. column :do_not_sort_me, :sortable => false
128
+ column :do_not_sort_me, :sortable => false
127
129
128
130
end
129
131
@@ -134,9 +136,9 @@ The index views in Active Admin include sorting by default.
134
136
135
137
Active Admin gives complete control over the output of the form by creating a thin DSL on top of
136
138
the fabulous DSL created by Formtastic (http://github.com/justinfrench/formtastic).
137
-
139
+
138
140
ActiveAdmin.register Post do
139
-
141
+
140
142
form do |f|
141
143
f.inputs "Details" do
142
144
f.input :title
0 commit comments