Re: [Rails] Using scaffolding

47 views
Skip to first unread message

Colin Law

unread,
Mar 20, 2013, 5:49:14 AM3/20/13
to rubyonra...@googlegroups.com
On 20 March 2013 00:47, G <iamnotre...@hotmail.com> wrote:
> Hi all,
>
> I've been following this online book:
> http://ruby.railstutorial.org/chapters/a-demo-app#sec-modeling_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:
> http://localhost:3000/users
>
>
> However I get this error:
>
> "Routing Error
>
> No route matches [GET] "/users"
>
> Try running rake routes for more information on available routes."

Have you restarted the server since you made the change? It is not
necessary to restart when changing model/view/controller files but if
any configuration files (such as routes.rb) are changed then it is
necessary to restart it.

Othewise, did you try running rake routes to show you the routes
available, as suggested? You may not yet be able to fully understand
the output but it is worth following the suggestion anyway.
Have a look at config/routes.rb. I would have expected the generate
scaffold command to have added something like

resources :users

to it.

>
>
> 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?

Assuming that you are running the commands from within the folder of
the second application then no. I presume you have run rails server
from within the second application.

Colin

G M

unread,
Mar 20, 2013, 6:17:25 AM3/20/13
to rubyonra...@googlegroups.com
Hi Colin,

Closing the terminal and restarting the server did the trick, thank you.


G :)

> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Colin Law

unread,
Mar 20, 2013, 6:23:59 AM3/20/13
to rubyonra...@googlegroups.com
On 20 March 2013 10:17, G M <iamnotre...@hotmail.com> wrote:
> Hi Colin,
>
> Closing the terminal and restarting the server did the trick, thank you.

You should be able to stop the server using Ctrl+C (on linux anyway).
Not sure about other systems.

Colin

G M

unread,
Mar 20, 2013, 6:34:25 AM3/20/13
to rubyonra...@googlegroups.com
I tried that a number of times but it didn't work, closing the terminal window was the only way to get it to work.

Colin Law

unread,
Mar 20, 2013, 9:29:01 AM3/20/13
to rubyonra...@googlegroups.com
On 20 March 2013 10:34, G M <iamnotre...@hotmail.com> wrote:
> I tried that a number of times but it didn't work, closing the terminal
> window was the only way to get it to work.

What do you mean "it didn't work"? Do you mean that it did not stop
the server or it stopped the server but restarting it did not fix the
problem? If the latter were you in the correct directory in the
terminal? If the former what OS are you using?

G M

unread,
Mar 20, 2013, 9:35:43 AM3/20/13
to rubyonra...@googlegroups.com
Restarting the server didn't fix the problem, I believe I was in the correct directory but that maybe was the problem.  I've since closed the terminal down and it's now working.  This is certainly the fastest setup I've ever experienced in getting a framework up and running.  Hopefully today's progress will be good too!


Cheers,

G

Kishore Seemala

unread,
Feb 6, 2014, 5:49:28 AM2/6/14
to rubyonra...@googlegroups.com
Maybe the routes.rb has not been updated with the new resource users.
Once check the routes.rb under config folder in your application and
place "resources :users", if it is missing
Or you can also check the url http://localhost:3000/users/index,
sometimes its problem with scaffolding

--
Posted via http://www.ruby-forum.com/.
Reply all
Reply to author
Forward
0 new messages