Ruby noob在这里,我创建了一个搜索表单,我正在尝试查询数据库并显示结果。我在StaticPages #home中收到NoMethodError 随着.... /home/action/Projects/CodonCoderTest5/app/views/static_pages/home.html.erb第4行提出:
未定义的方法`each'代表nil:NilClass
我哪里错了?
布局/ StaticPages /家
<h1>StaticPages#home</h1>
<% @data_bases.each do |list| %>
<div class="list">
<h1 class="list-mrnaCodon"><%= link_to list.mrnaCodon %></h1>
</div>
<% end %>
控制器
class DataBaseController < ApplicationController
def new
end
def index
if params[:search]
@data_bases = Match.search(params[:search]).order("created_at DESC")
else
@data_bases = Match.order("created_at DESC")
end
end
end