Topic: Using scaffolding

Hi all,

I've been following this online book: … demo_users

I ran the commands:
rails generate scaffold User name:string email:string
bundle exec rake db:migrate

As I understand it I should be able to go to the following URL and it should display a list of users:

However I get this error:

"Routing Error

No route matches [GET] "/users"

Try running rake routes for more information on available routes."

In the first chapter another application was created, could it be that the rails server is serving the first application instead of the one from the second chapter of the book?

Anyone any idea how to fix this issue?

Thanks in advance.


Last edited by CaptainChainsaw (2013-03-19 19:45:52)

Re: Using scaffolding

if you run "rake routes" from the command line inside the root folder of your rails app what output do you get?

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Using scaffolding

I'm getting this:

CC@ubuntu:~/demo_app$ rake routes
    users GET    /users(.:format)          users#index
          POST   /users(.:format)          users#create
new_user GET    /users/new(.:format)      users#new
edit_user GET    /users/:id/edit(.:format) users#edit
     user GET    /users/:id(.:format)      users#show
          PUT    /users/:id(.:format)      users#update
          DELETE /users/:id(.:format)      users#destroy

Re: Using scaffolding

Do you have a second session window open? Maybe the app you're running is not the one you scaffolded users in.

Re: Using scaffolding

I did have a second terminal tab open, although I did try running the command again I got:

CC@ubuntu:~/demo_app$ rails generate scaffold User name:string email:string
      invoke  active_record
Another migration is already named create_users: /home/graeme/demo_app/db/migrate/20130319222936_create_users.rb

Closed the terminal down and restarted the server, all working now smile

Thank you smile