I followed every line of the tutorial
but I get this error
Showing /home/ubuntu/blog/app/views/articles/index.html.erb where line
#9
raised:
undefined method `each’ for nil:NilClass
<% @articles.each do |article| %>
<%= article.title %>
<%= article.text %>
if you think that might not have returned the articles in the
controller,
thats not true :
here is code for my controller :
$ cat app/controllers/articles_controller.rb
class ArticlesController < ApplicationController
def index
-
@articles = Article.all*
end
and here is code for my view
$ cat app/views/articles/index.html.erb
Listing articles
<% @articles.each do |article| %>*
<td><%= article.title %></td>*
<td><%= article.text %></td>*
<% end %>*
Title | Text |
---|---|
The code works for showing one article but not for showing all articles