Created
September 21, 2011 19:33
-
-
Save rwilcox/1233059 to your computer and use it in GitHub Desktop.
presenter_pattern_gone_wrong?
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
| # If the item has one comment, show it, else show the last comment and allow the user to expand | |
| # (yes, a slightly contrived example) | |
| def primary_comment | |
| if self.comemnts.count > 1 | |
| "<details class='primary_comment details'><summary><h3>" + self.comments.last.text + " (and #{self.comments.count - 1} others)" | |
| "<ul>" | |
| self.comments.each[0...-1] do |comment| | |
| "<li>" + comment.text + "</li>" | |
| end | |
| else | |
| "<span class='primary_url'>" + self.comments.last.text + "</span>" | |
| end | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The cunning conclusion to this story can be found on my blog: http://rwilcox.tumblr.com/post/10546160404/presenter-pattern-rails-3-and-html-safe