Skip to content

Instantly share code, notes, and snippets.

@edavis10
Created December 13, 2011 19:47
Show Gist options
  • Save edavis10/1473581 to your computer and use it in GitHub Desktop.
Save edavis10/1473581 to your computer and use it in GitHub Desktop.
# I think we can agree that this code is best, even if contrived:
if @article.public?
views += 1
else
redirect_to "/some/other/page"
end
# But sometimes, people don't make query methods that are positive, ie
unless @article.draft?
redirect_to "/some/other/page"
else
views +=1
end
# I think that's better than:
if not @article.draft?
# But that's really just taste. In order to not use unless/else, you need to
# make sure your ? methods are asking a positive question, not a negative one.
# Which is ideal, but none of us are always working on ideal code, right?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment