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
*<h1>Listing articles</h1>*
*<table>*
* <tr>*
* <th>Title</th>*
* <th>Text</th>*
* </tr>*
* <% @articles.each do |article| %>*
* <tr>*
* <td><%= article.title %></td>*
* <td><%= article.text %></td>*
* </tr>*
* <% end %>*
*</table>*
The code works for showing one article but not for showing all articles
*http://localhost:3000/articles*
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/c0e36d2f-8b86-4714-b2c1-d90beb9428ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.