This isn't doing what I'm guessing you think it's doing. The code between <% %> is evaluated *by the server* as part of processing the erb file to prepare the html to return. So what's actually happening here is that, in the course of generating the index page, it's clearing the session -- i.e. even before it sends the response back to the browser. So your Sign Out link isn't really doing anything, it's just re-displaying the index page. Same behavior as if you simply refreshed the page. Note that the return value from "session.clear" is nil, so what's actually in the html is <a href=" /">Sign Out</a>