我找不到错误,这让我发疯

I can't find the error and it's driving me crazy

这是我的 index.html.erb Post#index

我收到这个错误:

/home/ubuntu/workspace/app/views/posts/index.html.erb:34: syntax error, unexpected '\n', expecting &. or :: or '[' or '.'

请帮忙!

<div class="title">

        <h1>All Posts</h1>
    </div>
    <div id="post_list">
        <% for @posts.each do |p| %>
            <div class="post_title">
                <h2><%= p.date.strftime("%Y%m%d") %></h2>
            </div>
            <div class="post_type">
                <h3><%= p.type %></h3>
            </div>
            <div class="post_content">
                <p><%= p.content %></p>
            </div>
                <% unless p.is_cited='false' %>
                    <div class="post_citation">
                        <p><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%= p.citation %></i></p>
                    </div>
                <% end %>
                </br>
                <div class="button">
                    <div class="action_buttons">
                        <div class="show">
                            <%= link_to 'Show', @post %>  
                        </div>
                        <div class="edit">
                            <%= link_to 'Edit', edit_post_path %>
                        </div>
                        <div class="delete">
                            <%= link_to 'Delete', post_path(@post), data: {confirm: "Are you sure?"}, :method => :delete %>
                        </div>
                    </div>
                </div> 
            <% end %>
    </div>

而不是以下内容:

<% for @posts.each do |p| %>

尝试:

<% @posts.each do |p| %>

不确定这是否是导致问题的原因,但您在每个块中引用了@post。尝试改变

<%= link_to 'Show', @post %>

<%= link_to 'Show', p %>

并改变

<%= link_to 'Delete', post_path(@post), data: {confirm: "Are you sure?"}, :method => :delete %>

<%= link_to 'Delete', post_path(p), data: {confirm: "Are you sure?"}, :method => :delete %>