Skip to content

Instantly share code, notes, and snippets.

@stoplion
Created September 12, 2012 20:45
Show Gist options
  • Save stoplion/3709781 to your computer and use it in GitHub Desktop.
Save stoplion/3709781 to your computer and use it in GitHub Desktop.
Needed a method like link_to_unless_current but that takes a block for both failing/passing conditions and either creates a link or not from the block
def make_anchor_unless_current(options={})
if current_page?(options)
content_tag(:span, class: 'current') do
yield
end
else
link_to options do
yield
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment