【发布时间】:2021-08-06 17:05:26
【问题描述】:
结束时出现意外结束,但我看不出问题出在哪里。 我的终端一直给我错误:ActionView::SyntaxErrorInTemplate (Encountered a syntax error while rendering template:
我的个人资料.html.erb
<% if @users.image.present? %>
<%= image_tag @users.image %>
<% end %>
<strong><h1><%= @users.full_name %></h1></strong>
<% if user_signed_in? %>
<% if @user == current_user %>
<%= link_to"Edit Profile", edit_user_registration_path(@user) %>
<% if user_signed_in? && !@user? %>
<% if current_user.following?(@user) %>
<%= link_to"Unfollow", follows_path(user_id: @user.id), method: :delete %>
<% else %>
<%= link_to"Follow", follows_path(user_id: @user.id) %>
<% end %>
<% end %>
<% end %>
<% end %>
<div> <%= @users.posts.count %> Posts </div>
<p><%= @users.full_name %></p>
<p><%= @users.description %></p>
<p><%= link_to @users.website if @users.website.present? %></p>
<%= @posts.each do |post|%>
<%= image_tag post.image %>
<% end %>
【问题讨论】:
-
首先查看错误消息并找到有问题的行。我猜它连接到
<% end %> <% end %> <% end %>。 -
代码没有正确缩进时很难发现这样的错误。
标签: html ruby-on-rails ruby erb ruby-on-rails-6