module ActionView::Helpers::UrlHelper

def link_to_unless_current(name, options = {}, html_options = {}, &block)

%>
end
link_to("Go back", { :controller => "posts", :action => "index" })
link_to_unless_current("Comment", { :controller => "comments", :action => "new" }) do
<%=

"Go Back" link instead of a link to the comments page, we could do something like this...
action is the action given. So, if we had a comments page and wanted to render a
The implicit block given to +link_to_unless_current+ is evaluated if the current


  • About Us

  • Home


  • About Us

  • Home


  • <%= link_to_unless_current("About Us", { :action => "about" }) %>

  • <%= link_to_unless_current("Home", { :action => "index" }) %>

  • def link_to_unless_current(name, options = {}, html_options = {}, &block)
      link_to_unless current_page?(options), name, options, html_options, &block
    end