Created
November 5, 2010 23:02
-
-
Save wmeister-old/665018 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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