Created
July 27, 2012 23:55
-
-
Save jessieay/3191122 to your computer and use it in GitHub Desktop.
REFACTORING :)
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
def value | |
@values = 0 | |
Post.find(self.id).votes.each do |vote| | |
if vote.vote_value == nil | |
vote.vote_value = 0 | |
else | |
@values += vote.vote_value | |
end | |
end | |
@values | |
end | |
def value | |
values = 0 | |
Post.find(self.id).votes.each { |vote| vote.vote_value ? values += vote.vote_value : values += 0} | |
values | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment