Skip to content

Instantly share code, notes, and snippets.

@adrianshort
Created January 8, 2012 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adrianshort/1579512 to your computer and use it in GitHub Desktop.
Save adrianshort/1579512 to your computer and use it in GitHub Desktop.
- @last_date = ''
- @results.each do |row|
- if row.election_d != @last_date
- @last_date = row.election_d
%h2= row.election_d
%table
%tr
%td{ :style => "background-color: #{row.party_colour}" }
 
%td= row.party_name
%td= row.c_surname
%td= to_ordinal(row.position)
%td= commify(row.votes)
@adrianshort
Copy link
Author

Thanks for that. I hadn't heard of group_by before but I can see how that's useful.

In the end I simplified it by using nested loops around first the elections and then the candidacies for each election as in this commit.

Here it is in action.

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