我正在运行此视图
<header>
<h1 class="h2">Users</h1>
</header>
<section class="search-form">
<form>
<%= form_for :users, method: :get do |f| %>
<div class="input-group input-sm">
<%= label_tag :keywords, nil, class: "sr-only" %>
<%= text_field_tag :keywords, nil, placeholder: "Search for first name, last name or email address", class: "form-control input-sm"%>
<span class="input-group-btn"><%= submit_tag "Find", class: "btn btn-primary btn-sm" %>
</span>
</div>
<% end %>
</form>
<!-- <h4 class="searchedFor"> <small>Searched for: to be added</small></h4>-->
</section>
<section class="search-results">
<header><h3>Results</h3></header>
<ol class="list-group">
<%= @users.each do |user| %>
<li class="list-group-item clearfix">
<h3 class="pull-right"><small class="text-uppercase">created </small><%= user.created_at.to_time %></h3>
<h2 class="h3"><%= user.first_name %> <%= user.last_name %><small> <%= user.username %></small></h2>
<%= link_to "Show", users_path(@user), class: "pull-right" %>
<h4><%= user.email %></h4>
</li>
<% end %>
</ol>
</section>
虽然其余的搜索和表单功能都可以,但我的页面底部有一个文本节点(见截图),我不知道为什么???
答案 0 :(得分:1)
将loops
周围的erb块从<%=
更改为<%
。否则你就像现在一样将枚举器本身打印到屏幕上。
自:
<%= @users.each do |user| %>
要:
<% @users.each do |user| %>