In the Beginning Ruby: From Novice to Professional book Chapter 13 focuses on the frameworks that were most popular at the time of the writing; Rails, of course, featuring prominently.
The project that is used to introduce the concepts has a section which extends the generic application created with the rails command by adding a view_all method to the scaffold:
def view_all @Entries = Entry.all(:order => 'created_at DESC') end It also points out that the config/routes.rb file contains the following:
map.resources :entries and to update to be
map.resources :entries, :collection => { :view_all => :get } The problem is that my config/routes.rb file does not look exactly like that. It does not have the map. portion and just looks like
resources :entries I added the :collection... portion anyway.
The book then says to add the following to app/views/entries/view_all.html.erb
<% @entries.each do |entry| %> <h1><%= entry.title %></h1> <p><%= entry.content %></p> <p><em>Posted at <%= entry.created_at %></em></p> <% end %> <%= link_to 'Add New entry', new_entry_path %> I've done all of this, but when I attempt to run the "application" I get an error
Couldn't find Entry with id=view_all with the parameters as
{"collection"=>{"view_all"=>:get}, "id"=>"view_all"} Has anyone else either looked at the book and seen how it is a bit out of date and know a fix for this or at least have a general understanding of what I'm doing wrong?