Last active
August 29, 2015 14:14
-
-
Save masonfmatthews/485ec9d016013b361922 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module ItemsHelper | |
def display_array_contents(items) | |
result = "<table>" | |
items.each do |i| | |
result << "<tr>" | |
result << "<td>#{i.name}</td>" | |
result << "<td>#{i.price}</td>" | |
result << "</tr>" | |
end | |
result << "</table>" | |
end | |
result.html_safe | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This helper makes a table with one row for each thing in the array you pass to it. Each row of the HTML table will have two columns, and this assumes that each thing in the items array will respond to .name and .price.