zhiguang
2008-Jun-22 19:06 UTC
Routing Error No route matches "/employee/list" with {:method=>:get}
hi, I am very frustrated by this error when I just put together a very simple project from one of the textbook on RoR: Routing Error No route matches "/employee/list" with {:method=>:get} For your reference, #The following is EmployeesController.rb class EmployeesController < ApplicationController scaffold :employee # create scaffold code for controller # override scaffold list method def list @employees = Employee.find( :all ) # return an array of all Employees end # method list end # class EmployeeController # The following is Employee.rb class Employee < ActiveRecord::Base end # And the following is list.rhtml, <?xml version = "1.0" encoding = "utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!-- Fig. 20.22 app/views/employees/list.rhtml --> <!-- A view that displays a list of Employees. --> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>List of Employees</title> </head> <body style="background-color: lightyellow"> <h1>List of Employees</h1> <ol> <% for employee in @employees %> <!-- create a list item for every employee with his full name --> <li><%= employee.first_name %> <%= employee.last_name %></li> <% end %> </ol> </body> </html> PLEASE HELP!!! Zhiguang --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Jun-22 21:49 UTC
Re: Routing Error No route matches "/employee/list" with {:method=>:get}
On 22 Jun 2008, at 20:06, zhiguang wrote:> > hi, > > I am very frustrated by this error when I just put together a very > simple project from one of the textbook on RoR: > Routing Error > No route matches "/employee/list" with {:method=>:get} > > For your reference, > > #The following is EmployeesController.rb > > class EmployeesController < ApplicationControllerif your controller is employees then (in the absence of any extra routes being defined) the url you should be hitting is /employees/list Fred --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
zhiguang
2008-Jun-23 01:51 UTC
Re: Routing Error No route matches "/employee/list" with {:method=>:get}
Yes that fixes it, but only if I comment out the line scaffold :employee # create scaffold code for controller in EmployeesController.rb. If I keep that line there, I still have trouble when hitting /employees/new etc. I think I need help with the way how "scaffold" works. Thanks! On Jun 22, 5:49 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 22 Jun 2008, at 20:06, zhiguang wrote: > > > > > hi, > > > I am very frustrated by this error when I just put together a very > > simple project from one of the textbook on RoR: > > Routing Error > > No route matches "/employee/list" with {:method=>:get} > > > For your reference, > > > #The following is EmployeesController.rb > > > class EmployeesController < ApplicationController > > if your controller is employees then (in the absence of any extra > routes being defined) the url you should be hitting is /employees/list > > Fred--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jeremy McAnally
2008-Jun-23 03:40 UTC
Re: Routing Error No route matches "/employee/list" with {:method=>:get}
That macro was removed from recent versions of Rails. It sounds like your book is rather out of date unfortunately. You can still generate scaffolding like so (from the command line): script/generate scaffold employees That will give you the controller, model, and test files rather than generating most of the code at runtime like the scaffold method did before. --Jeremy On Sun, Jun 22, 2008 at 8:51 PM, zhiguang <XuZhiguang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Yes that fixes it, but only if I comment out the line > > scaffold :employee # create scaffold code for controller > > in EmployeesController.rb. If I keep that line there, I still have > trouble when hitting /employees/new etc. > > I think I need help with the way how "scaffold" works. Thanks! > > On Jun 22, 5:49 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> On 22 Jun 2008, at 20:06, zhiguang wrote: >> >> >> >> > hi, >> >> > I am very frustrated by this error when I just put together a very >> > simple project from one of the textbook on RoR: >> > Routing Error >> > No route matches "/employee/list" with {:method=>:get} >> >> > For your reference, >> >> > #The following is EmployeesController.rb >> >> > class EmployeesController < ApplicationController >> >> if your controller is employees then (in the absence of any extra >> routes being defined) the url you should be hitting is /employees/list >> >> Fred > > >-- http://jeremymcanally.com/ http://entp.com Read my books: Ruby in Practice (http://manning.com/mcanally/) My free Ruby e-book (http://humblelittlerubybook.com/) Or, my blogs: http://mrneighborly.com http://rubyinpractice.com --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---