Rails显示数据库中不需要的文本

时间:2018-12-09 19:48:33

标签: ruby-on-rails

Rails正在显示来自数据库(sqlite3)的有害内容,如下所示:

Recipes
Cookies

Text here

Cake

Text here
[#<Recipe id: 50, name: "Cookies", Recipe: "Text here", created_at: "2018-12-09 05:36:46", updated_at: "2018-12-09 05:36:46">, #<Recipe id: 51, name: "Cake", scam: "Text here", created_at: "2018-12-09 18:54:11", updated_at: "2018-12-09 18:54:11">] 

控制器位于here中。

查看代码

<!DOCTYPE html>
<html>
  <head>
    <title>Recipe Masterlist</title>
  </head>
  <body>
   <h1>Recipes</h1>
   <%= @recipes.each do |s| %>
    <span class="name"><%= s.name %></span>
    <p><%= s.recipe %></p>
   <% end %>
  </body>
</html>

1 个答案:

答案 0 :(得分:2)

更改此行

<%= @recipes.each do |s| %>

对此

<% @recipes.each do |s| %>

=显示代码内的内容。我怀疑那是你的罪魁祸首

相关问题