Error with Ejs: Cannot read equals of undefined
Closed this issue · 4 comments
twhite96 commented
The equals
method in the show template is throwing an error: cannot read 'equals' of undefined
. I have the same file as you but I am not sure what's happening.
</div>
<div class="col-md-9">
<div class="thumbnail">
<img class="img-responsive" src="<%= campground.image %>">
<div class="caption-full">
<h4 class="pull-right">
$<%= campground.cost %>/night
</h4>
<h4><a><%=campground.name%></a></h4>
<p><%= campground.description %></p>
<p>
<em>Submitted by: <%= campground.author.username %>, <%= moment(campground.createdAt).fromNow() %></em>
</p>
<% if(currentUser && campground.author.id.equals(currentUser._id) || currentUser && currentUser.isAdmin){ %>
<a class="btn btn-warning" href="/campgrounds/<%= campground._id %>/edit">Edit</a>
<form action="/campgrounds/<%= campground._id %>?_method=DELETE" method="POST" class="delete-form">
<button class="btn btn-danger">Delete</button>
</form>
<% } %>
</div>
</div>
<div class="well">
<div class="text-right">
<a class="btn btn-success" href="/campgrounds/<%= campground._id %>/comments/new">Add New Comment</a>
</div>
<hr>
<% campground.comments.forEach(function(comment){ %>
<div class="row">
<div class="col-md-12">
<strong><%= comment.author.username %></strong>
<span class="pull-right"><%= moment(comment.createdAt).fromNow() %></span>
<div>
<%= comment.text %>
<% if(currentUser && comment.author.id.equals(currentUser._id) || currentUser && currentUser.isAdmin){ %>
<div class="pull-right">
<a href="/campgrounds/<%=campground._id%>/comments/<%=comment._id%>/edit" class="btn btn-xs btn-warning">EDIT</a>
<form class="delete-form" action="/campgrounds/<%=campground._id%>/comments/<%=comment._id%>?_method=DELETE" method="POST">
<button class="btn btn-xs btn-danger">DELETE</button>
</form>
</div>
<% } %>
<hr>
</div>
</div>
</div>
<% }) %>
</div>
</div>
</div>
twhite96 commented
Found the answer in the comments on The Web Developer Bootcamp. Closing this now.
jiaquan1 commented
Hi I got the same error, did not find the answer yet. Could you help to put the link of the answer? Great thanks!
INDALPHA commented
can you tell the solution?
twhite96 commented
I'm sorry guys but I haven't opened this in years now. I'll reopen this just in case one of the maintainers can help out.