Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Link_to_remote_unless_current

DZone's Guide to

Link_to_remote_unless_current

·
Free Resource
// Full discussion about this available at:
// http://6brand.com/articles/2006/06/07/link_to_remote_unless_current


# throw this in one of your controller helpers.
# it works just like a combination of link_to_unless_current and link_to_remote
def link_to_remote_unless_current(name, options = {}, html_options = {}, *parameters_for_method_reference, █)
  if current_page?(options[:url])
    if block_given?
      block.arity <= 1 ? yield(name) : yield(name, remote_function(options), html_options, *parameters_for_method_reference)
    else
      name
    end
  else
    link_to_function(name, remote_function(options), html_options)
  end
end
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}