Skip to content

Instantly share code, notes, and snippets.

@wmeister-old
Created November 5, 2010 23:02
Show Gist options
  • Save wmeister-old/665018 to your computer and use it in GitHub Desktop.
Save wmeister-old/665018 to your computer and use it in GitHub Desktop.
def table_for(models, header, &block)
tbody = models.map{|m| ['<tr>', block.call(m).map{|d| "<td>#{d}</td>"}, '</tr>'] }.flatten.join
'<table><thead><tr>' + header.map{|h| "<td>#{h.is_a?(Symbol) ? h.to_s.capitalize : h}</td>"}.join + "</tr><tbody>#{tbody}</tbody></table>"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment