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| %>
<tr>
<td><%= article.title %></td>
<td><%= article.text %></td>
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| %>
<% end %>
Title Text <%= article.title %> <%= article.text %>
The code works for showing one article but not for showing all articles