Skip to content

Adding more links to site navigation

Ronald Chan edited this page Feb 26, 2012 · 3 revisions

This guide assumes you already have site-wide navigation set up.

Suppose you already have a link, eg:

<%= link_to "New Post", new_post_path %>

Simply change the link_to helper to use the ajax_link_to helper, and say which pagination section name you gave for the site-wide navigation.

<%= ajax_link_to "New Post", posts_post_path, :pagination => "" %>

However, because the default is already the empty string (you did follow our advice in that guide, naming your site-wide navigation with an empty string... right?), you can shorten that to:

<%= ajax_link_to "New Post", posts_post_path %>

For adding AJAX links in general, and for more detail, see Creating AJAX links