Skip to content

Instantly share code, notes, and snippets.

@delba
Created July 18, 2013 02:04
Show Gist options
  • Select an option

  • Save delba/6026166 to your computer and use it in GitHub Desktop.

Select an option

Save delba/6026166 to your computer and use it in GitHub Desktop.
def link_to_next(article)
target = article.next || Article.new(date: Date.today)
link_to "next", target.today? ? root_path : target
end
# do not initialize an Article
def link_to_next(article)
target = article.next
link_to "next", target.try('!today?') ? target : root_path
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment