Skip to content

Commit d5ee9d0

Browse files
committed
Updated README with new syntax
1 parent 34b58de commit d5ee9d0

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

README.rdoc

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -59,32 +59,34 @@ If all you need to do is change the columns which get displayed, you can do so b
5959
them to the columns method:
6060

6161
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
6567
end
6668

6769
end
6870

6971
Or you can pass them in individually:
7072

7173
ActiveAdmin.register Post do
72-
73-
index do |display|
74+
75+
index do
7476

7577
# This will title the column 'Title' and call the #title method on each object
76-
display.column :title
78+
column :title
7779

7880
# 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
8082

8183
# You can add methods to the table builder which builds common things (ie: selectable checkboxes)
82-
display.default_actions
84+
default_actions
8385

8486
end
8587

8688
end
87-
89+
8890

8991
==== Advanced Columns
9092

@@ -94,11 +96,11 @@ example, say we wanted a colum called Title which holds a link to the posts admi
9496
You can pass a block to a column which will then be rendered within the context of the view
9597
for each of the objects in the collection.
9698

97-
99+
98100
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) }
102104
end
103105

104106
end
@@ -110,20 +112,20 @@ the block as an argument.
110112
==== Sorting
111113

112114
The index views in Active Admin include sorting by default.
113-
115+
114116
ActiveAdmin.register Post do
115-
116-
index do |display|
117+
118+
index do
117119

118120
# A column created by a method call assumes its sortable
119-
display.column :id
121+
column :id
120122

121123
# If a column is defined using a block, you must pass the key to turn on sorting. The key
122124
# 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) }
124126

125127
# Turn off sorting by passing false
126-
display.column :do_not_sort_me, :sortable => false
128+
column :do_not_sort_me, :sortable => false
127129

128130
end
129131

@@ -134,9 +136,9 @@ The index views in Active Admin include sorting by default.
134136

135137
Active Admin gives complete control over the output of the form by creating a thin DSL on top of
136138
the fabulous DSL created by Formtastic (http://github.com/justinfrench/formtastic).
137-
139+
138140
ActiveAdmin.register Post do
139-
141+
140142
form do |f|
141143
f.inputs "Details" do
142144
f.input :title

0 commit comments

Comments
 (0)