<%
  # Destroy old sessions if a user has been deleted
  begin
    User.find(session[:user]) if session[:user]
  rescue Mongoid::Errors::DocumentNotFound
    session = {}
    %>
      <script type="text/javascript">
        window.location.href="<%= homepage_path %>"
      </script>
    <%
  end
%>
<%
  # Destroy old sessions if a user has been deleted
  begin
    User.find(session[:user]) if session[:user]
  rescue ActiveRecord::RecordNotFound
    session = {}
    %>
      <script type="text/javascript">
        window.location.href="<%= homepage_path %>"
      </script>
    <%
  end
%>
Change Mongo reference to ActiveRecord reference
Change Mongo reference to ActiveRecord reference
