11.2.5 A working follow button with Ajax

Although our user following implementation is complete as it stands, we
have one bit of polish left to add before starting work on the status
feed. You may have noticed in Section 11.2.4 that both the create and
destroy actions in the Relationships controller simply redirect back to
the original profile. In other words, a user starts on a profile page,
follows the user, and is immediately redirected back to the original
page. It is reasonable to ask why the user needs to leave that page at
all.

This is exactly the problem solved by Ajax, which allows web pages to
send requests asynchronously to the server without leaving the page.8
Because the practice of adding Ajax to web forms is quite common, Rails
makes Ajax easy to implement.