Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def matrix_for(collection,row_attribute,col_attribute,display_attribute)
- returnstring = "<table>\n"
- returnstring += ([" <tr>\n <td>\n"] + entries_for(collection,col_attribute)).join("\n </td>\n <td>\n") + "\n </td>\n </tr>\n"
- entries_for(collection,row_attribute).each do |row|
- r = [" <tr>\n <td>\n#{row}"]
- entries_for(collection,col_attribute).each do |column|
- r << collection.select{|p| p.send(col_attribute) == column && p.send(row_attribute) == row}.map{|p| p.send(display_attribute)}.join("<br/>\n")
- end
- returnstring += r.join("\n </td>\n <td>") + "\n </td>\n </tr>\n"
- end
- returnstring + "</table>"
- end
Add Comment
Please, Sign In to add comment