Forum: Ruby on Rails Keep getting "Undefined local variable or method" when creating a new rails application

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Beb127032d16730a7f6247b809142ec6?d=identicon&s=25 command0 (Guest)
on 2008-10-16 04:02
(Received via mailing list)
Hi, I'm fairly a noob to rails, and just trying to grasp the entire
structure and concept. I think I'm getting it for the most part, but
just can't seem to get past this error.

I keep getting "Action Controller" page with the error:

"undefined local variable or method `new_courses_path' for
#<ActionView::Base:0x23370f0>".

Ok, so let me tell you what I am doing so that you can understand. I
create a mysql connected rails app called training. So there is no
confusion, I have already created the database, and it works fine.

prompt>rails -d mysql training

Ok, so that is created. Then I create a scaffold to save time from
having to create the model, view, and controller. And I create it
telling it which db fields to create with it. To make this example
simple, I'll just do 3 db fields: title (the course title) of varchar,
description (course description) as text, and course_num (to locate
the course faster in the db) as an integer.

prompt>cd training
prompt>script/generate scaffold courses \
> title:string description:text course_num:integer

And then I hit enter. It generates my model, view, and controller for
me, so then I fire up Mongrel.

prompt>script\server

And then I go to localhost:3000/courses in my browser, and thats when
I get the error. I just cannot figure it out. I've created another app
with different names, bla bla bla, and it worked fine. Its just got me
stumped.

If someone could help me get some insight on the issue, it'd be much
appreciated.

Thanks,

Justin
Beb127032d16730a7f6247b809142ec6?d=identicon&s=25 command0 (Guest)
on 2008-10-16 04:21
(Received via mailing list)
Oh Yes, and I forgot to mention I step I did in between. After
generating the scaffold, then I'd migrate the database.

prompt>rake db:migrate

Just wanted to throw that in there so nobody mentions me missing that
step, lol :P

Thanks,

Justin
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-10-16 05:43
(Received via mailing list)
On 15 Oct 2008, at 23:07, command0 wrote:

>
> Oh Yes, and I forgot to mention I step I did in between. After
> generating the scaffold, then I'd migrate the database.
>
script/generate scaffold is expecting the singular name, not the plural.

Fred
D6434aa0b7b350f8c3ed0119d81b2ead?d=identicon&s=25 Roy Pardee (rpardee)
on 2008-10-16 14:34
(Received via mailing list)
I think your problem is that you used the plural "courses" on your call
to script/generate scaffold.  That generator wants a *singular* noun.
So do a:

  rake db:rollback

and

  script/destroy scaffold courses

followed by a:

  script/generate scaffold course title:string description:text
course_num:integer

and

  rake db:migrate

And you should be good.

HTH,

-Roy
Beb127032d16730a7f6247b809142ec6?d=identicon&s=25 command0 (Guest)
on 2008-10-16 20:38
(Received via mailing list)
That was it. I had no idea it had a singular naming convention in that
sense.

Thank you very much to all of you for your help. I'll keep that in
mind for now on :).

Thanks,

Justin
This topic is locked and can not be replied to.