【问题标题】:rails SyntaxError unexpected in, expecting then or ';' or '\n'rails SyntaxError 意外出现,期待 then 或 ';'或'\n'
【发布时间】:2020-10-28 11:35:16
【问题描述】:

错误描述是

SyntaxError: /workspace/SiUber/app/views/siuber/search.html.erb:128: syntax error, unexpected in, expecting then or ';' or '\n'
    if @se in ss.title
           ^~/workspace/SiUber/app/views/siuber/search.html.erb:139: syntax error, unexpected end, expecting end-of-input
      end
      ^~~
  '`<%
@search.each do |ss| 
    if @se in ss.title
        %>
        <hr>
        <h6><a href='<%= ss.link %>'><%= ss.title %></a></h6>
        <p>
            올린사람 : <%= ss.maker %>
        </p>
        <hr>
    <% end
end %>`

【问题讨论】:

  • 请格式化您的代码

标签: ruby-on-rails database


【解决方案1】:

我假设@se 是一个数组

所以请尝试下面的代码

<% @search.each do |ss|  %>
  <% if @se.include?(ss.title) %>
    <hr>
    <h6><a href='<%= ss.link %>'><%= ss.title %></a></h6>
    <p> 올린사람 : <%= ss.maker %> </p>
    <hr>
  <% end %>
<% end %>

如果它不起作用,请在此处添加完整代码。

【讨论】:

    猜你喜欢
    • 2014-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多