I have some javascript I would like to execute only if a user is logged into my rails app. I set up the user show page as follows:
<table class="profile" summary="Profile information">
<tr>
<td class="main">
<h1>
<%= gravatar_for @user %>
<%= @user.name %>
</h1>
<%= render 'follow_form' if signed_in? %>
<% end %>
</td>
<td class="sidebar round">
<strong>Name</strong> <%= @user.name %><br />
<strong>URL</strong> <%= link_to user_path(@user), @user %><br />
</td>
</tr>
</table>
<% if signed_in? %>
<div id="app-body">
<script type="text/javascript">
document.write("Hello World")
</script>
</div>
<% end %>
where signed_in? is a convenience method that returns a boolean if a user is logged in or not. The issue is when I try to load this page I get an error at one line past the end of the file:
syntax error, unexpected keyword_ensure, expecting $end
Extracted source (around line #48):
45: </div>
46:
47: <% end %>
Does anyone know how I can fix this error? All I find when I search are HAML indentation issues, but here I am using erb, so indentation shouldn't matter.