Skip to content

Commit e0b83c3

Browse files
committed
Added the ID column by default to resources on index tables
1 parent 2b7e025 commit e0b83c3

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

lib/active_admin/pages/index.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def main_content
3131
# with each column displayed as well as all the default actions
3232
def default_index_config
3333
@default_index_config ||= ::ActiveAdmin::PageConfig.new(:as => :table) do |display|
34+
display.id
3435
resource_class.content_columns.each do |column|
3536
display.column column.name.to_sym
3637
end

lib/active_admin/pages/index/table.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ def to_html(page_config, collection)
2121
#
2222
class TableBuilder < ::ActiveAdmin::TableBuilder
2323

24+
# Display a column for the id
25+
def id
26+
column 'ID', :id
27+
end
28+
2429
# Adds links to View, Edit and Delete
2530
def default_actions(options = {})
2631
options = {

spec/integration/index_as_table_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
it "should render a new link" do
4242
response.should have_tag("a", "New Post", :attributes => {:href => "/admin/posts/new"})
4343
end
44+
it "should render an ID header" do
45+
response.should have_tag("th", "ID")
46+
end
4447
it "should render a table with default sortable headers" do
4548
response.should have_tag("a", :content => "Title",
4649
:parent => { :tag => "th" })

0 commit comments

Comments
 (0)