Keep getting "Undefined local variable or method" when creating a new rails application

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

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 :stuck_out_tongue:

Thanks,

Justin

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

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

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