Ruby noob here, I created a search form and I am trying to query a db and display the results. I am getting NoMethodError in StaticPages#home along with.... /home/action/Projects/CodonCoderTest5/app/views/static_pages/home.html.erb where line #4 raised:
undefined method `each' for nil:NilClass
Where am I going wrong?
layouts/StaticPages/home
<h1>StaticPages#home</h1>
<% @data_bases.each do |list| %>
<div class="list">
<h1 class="list-mrnaCodon"><%= link_to list.mrnaCodon %></h1>
</div>
<% end %>
controller
class DataBaseController < ApplicationController
def new
end
def index
if params[:search]
@data_base = Match.search(params[:search]).order("created_at DESC")
else
@data_base = Match.order("created_at DESC")
end
end
def index
@data_bases = Match.all
end
end
Aucun commentaire:
Enregistrer un commentaire