Skip to content

Instantly share code, notes, and snippets.

@masonfmatthews
Last active August 29, 2015 14:14
Show Gist options
  • Save masonfmatthews/485ec9d016013b361922 to your computer and use it in GitHub Desktop.
Save masonfmatthews/485ec9d016013b361922 to your computer and use it in GitHub Desktop.
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
@masonfmatthews
Copy link
Author

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.

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