有没有人能告诉我为什么这段文字会突然出现在我的Rails 7应用程序上。我已经在scss、js和html上倾注,无法找到呈现它的内容。此外,该应用程序还包含另一个对象(称为employee,而不是模板),并在源代码中使用完全相同的内容,但它确实添加了这个纯文本。
它们之间唯一的区别是,我在模态和无模态中使用这个对象,但是两者都使用turbo框架。我很乐意发布一些代码,但我认为可能有人会很容易地首先识别它。
这是部分。
<%= @templates.each do |temp| %>
<div class="template__actions">
<div class="line-item__name">
<%= temp.name %>
</div>
<%= link_to "<i class='bi bi-trash'
style='font-size: 1.5rem; color:
red;'></i>".html_safe,
[temp],
data: {"turbo-method": :delete},
form: { data: {turbo_frame: "_top" } },
class:"btn btn--light staff_icon" %>
<%= link_to "<i class='bi bi-pencil-square'
style='font-size: 1.5rem; color:
black;'></i>".html_safe,
[:edit, temp],
class:"btn btn--light staff_icon" %>
</div>
<% end %>

发布于 2022-08-09 15:52:38
这是你的问题:
<%= @templates.each do |temp| %>等号使它打印模板数组。改为:
<% @templates.each do |temp| %>`发布于 2022-08-09 15:52:29
您正在以erb语法打印循环。
<%=用于打印返回,并且在循环结束时隐式返回集合。
相反,只需使用<%声明erb,而不是打印返回。
更改项目1
<%= @templates.each do |temp| %>至
<% @templates.each do |temp| %>https://stackoverflow.com/questions/73294038
复制相似问题