html - 为什么在 html 页面中有一个包含数据库记录的文本节点?
问题描述
所以在我的网站上,有一个不需要的文本节点,其中包含我的数据库记录。html 代码上没有任何标签或元素,但它以某种方式存在。
我认为这是由这行代码引起的:
<%= @workspace.items.each do |item| %>
<tr>
<td><%= item.name %></td>
<td><%= item.owner %></td>
<td><%= item.quantity %></td>
<td><%= item.details %></td>
<td><%= link_to 'Edit Item', edit_workspace_item_path(@workspace,item) %></td>
<td><%= link_to 'Delete', [item.workspace, item],
method: :delete,
data: { confirm: 'Are you sure?' } %></td>
</tr>
view.html.erb:
<p>
<strong>Name:</strong>
<%= @workspace.name %>
</p>
<p>
<strong>maxitem:</strong>
<%= @workspace.max %>
</p>
<p>
<strong>details:</strong>
<%= @workspace.details %>
</p>
<p>
<%= link_to 'Edit Phase', edit_workspace_path(@workspace) %>
</p>
<p><strong>Items</strong>
</p>
<p>
<%= link_to 'Add Item', new_workspace_item_path(@workspace) %></br>
</p>
<table>
<tr>
<tr>
<th><strong>Name</strong>
<th><strong>Owner</strong>
<th><strong>Quantity</strong>
<th><strong>Details</strong>
</tr>
<%= render 'items/item' %>
</table>
<%= link_to 'Back to List of Phases', workspaces_path %>
我不知道为什么这突然出现在我的网站 上
解决方案
<%= @workspace.items.each do |item| %>
是问题,因为<%= %>
ERB 代表“打印这个”。应该是<% %>
哪个将执行 Ruby 代码而不渲染它。
推荐阅读
- oracle - 无法在 Mac OS 中连接 SQL Developer
- powershell - 每次运行时的注册表值
- import - 在 AVA 中,如何将变量从测试文件导入另一个测试文件
- ansible - Ansible 嵌套循环和 jinja2 过滤器
- html - 在悬停类一上更改第二类
- javascript - 单击图标时,如何在用户对象中设置 userId
- sublimetext3 - 为什么我的键绑定不适用于浏览器包中的视图?
- matlab - 如何将向量中的两个点与设置 y 值的线连接起来?
- javascript - 错误文档未在 IDE 中定义且无法在浏览器或 jsfiddle 中运行
- ios - 选择 WhatsApp 后从 UIActivityViewController 中删除活动项