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"?>
List of Employees
List of Employees
<% for employee in @employees %>
- <%= employee.first_name %> <%= employee.last_name %>
<% end %>
PLEASE HELP!!!
Zhiguang
On 22 Jun 2008, at 20:06, zhiguang wrote:
#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
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 C. [email protected]
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 [email protected] wrote:
On Jun 22, 5:49 pm, Frederick C. [email protected]
No route matches "/employee/list" with {:method=>:get}
Fred
–
http://jeremymcanally.com/
http://entp.com
Read my books:
Ruby in Practice (Ruby in Practice)
My free Ruby e-book (http://humblelittlerubybook.com/)
Or, my blogs:
http://rubyinpractice.com