Skip to content

Instantly share code, notes, and snippets.

@jancel
Created February 18, 2012 18:04
Show Gist options
  • Save jancel/1860426 to your computer and use it in GitHub Desktop.
Save jancel/1860426 to your computer and use it in GitHub Desktop.
def build_table
build_table_head
build_table_body unless @collection.blank?
end
versus
def build_table
build_table_head
build_table_body
end
@pcreux
Copy link

pcreux commented Feb 18, 2012

The first version is your fix?

@jancel
Copy link
Author

jancel commented Feb 18, 2012

yes. sorry, this is in... lib/active_admin/views/components/table_for

@jancel
Copy link
Author

jancel commented Feb 18, 2012

here is the actual git diff

diff --git a/lib/active_admin/views/components/table_for.rb b
index b3e846e..bb05ff1 100644
--- a/lib/active_admin/views/components/table_for.rb
+++ b/lib/active_admin/views/components/table_for.rb
@@ -12,7 +12,7 @@ module ActiveAdmin
@resource_class = options.delete(:i18n)
@collection = collection
@columns = []

  •    build_table
    
  •    build_table 
     super(options)
    
    end

@@ -50,7 +50,7 @@ module ActiveAdmin

   def build_table
     build_table_head
  •    build_table_body
    
  •    build_table_body unless @collection.blank?
    

    end

    def build_table_head

@jancel
Copy link
Author

jancel commented Feb 18, 2012

If we need to, we can also do this in build_table_body directly, the problem is that when a collection is blank, it is evaluating and still putting it in the tbody ([]) which ends up looking messy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment