On Apr 26, 4:15 am, Colin Law <clan...@googlemail.com> wrote: > On 26 April 2011 08:56, amrit pal pathak <amritpalpath...@gmail.com> wrote: > > > ... > > class BookController < ApplicationController > > def index > > @book =Book.new > > Think about what this is doing. What is @book? It is a new Book > object, not surprisingly. > > > > > > > > > > > end > > end > > > 1)Index.html.erb: > > > <h1>Books are coming soon!</h1> > > <h1>Listing Books</h1> > > <table> > > <tr> > > <th>Title</th> > > <th>Summary</th> > > <th></th> > > <th></th> > > <th></th> > > </tr> > > <% @book.each do |book| %> > > Above is the line the error is on, what is it supposed to be doing? > Please explain what you think it means.
I think it retrieves the book details like title and contents from database.But here it no use so am removing this block. <% @book.each do |book| %> <tr> <td><%= book.title %></td> <td><%= book.content %></td> </tr> <% end %> > > NoMethodError in Book#index > > > Showing /home/amrit/boook/app/views/book/index.html.erb where line #14 > > raised: > > > undefined method `each' for #<Book id: nil, created_at: nil, > > updated_at: nil> > > When you see an error it is not always easy for a beginner to work out > what it means. Please try and work it out for yourself before asking > here. What do you think it might mean? Also as I asked above, what > do you think that line is supposed to do? Amrit pal -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.