daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def matrix_for(collection,row_attribute,col_attribute,display_attribute)
  2.     returnstring = "<table>\n"
  3.     returnstring += ([" <tr>\n  <td>\n"] + entries_for(collection,col_attribute)).join("\n  </td>\n  <td>\n") + "\n  </td>\n </tr>\n"
  4.     entries_for(collection,row_attribute).each do |row|
  5.       r = [" <tr>\n  <td>\n#{row}"]
  6.       entries_for(collection,col_attribute).each do |column|
  7.         r << collection.select{|p| p.send(col_attribute) == column && p.send(row_attribute) == row}.map{|p| p.send(display_attribute)}.join("<br/>\n")
  8.       end
  9.       returnstring += r.join("\n  </td>\n  <td>") + "\n  </td>\n </tr>\n"
  10.     end
  11.     returnstring + "</table>"
  12.   end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top