Skip to content

Instantly share code, notes, and snippets.

@jessieay
Created July 27, 2012 23:55
Show Gist options
  • Save jessieay/3191122 to your computer and use it in GitHub Desktop.
Save jessieay/3191122 to your computer and use it in GitHub Desktop.
REFACTORING :)
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