scaffold and links created

I used scaffold command

     generate scaffold User username:string password:string email:string validation_code:string validated:boolean

and when i go to http://localhost:3000/users/ i get this error:

undefined local variable or method `new_user_path' for #<ActionView::Base:0x5f1c3f4>

25: 26: <br /> 27: 28: <%= link_to 'New user', new_user_path %>

Where is the local variable new_user_path supposed to be defined (the controller?).. and why didn't the script generate this?

Thanks

Ruby version 1.8.6 (i386-mswin32) RubyGems version 1.3.3 Rails version 2.2.2 Active Record version 2.2.2 Action Pack version 2.2.2 Active Resource version 2.2.2 Action Mailer version 2.2.2 Active Support version 2.2.2

add   map.resources :users

to your config/routes.rb file

tom

bandejapaisa wrote:

rake routes >routes.lst will write all the current route definitions to a file for you to view.

You may need to stop and restart your server (mongrel? webrick?) after running the scaffold command to reload the new routes associated with User.

Rails is ignoring your new method in the controller because you haven't told Rails about it in your routes.rb file.

If you add a method in the controller that is the target of an HTTP request, you'll need to add that method to the routes.rb file.

http://api.rubyonrails.org/classes/ActionController/Resources.html

Where you probably have:

map.resources :posts

you need to tell Rails about any added methods.

Added methods for a collection of posts goes into a :collection => {:action => :verb} hash. Added methods for a single post goes into a :member => {:action => :verb} hash.

:action is your controller method name, :verb is the HTTP verb, :get, :post, :put, :delete (or :any)

If you've implemented a 'remove_all' method for the collection of posts, as well as a generate_pdf method for a single post, your routes.rb might look like:

map.resources :posts, :collection => {:remove_all => :delete}, :member => {:generate_pdf => :get}