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

**URL:** <https://www.ruby-forum.com/t/keep-getting-undefined-local-variable-or-method-when-creating-a-new-rails-application/151033>\
**Category:** Rails\
**Created:** [October 16, 2008, 4:02am UTC](https://www.ruby-forum.com/t/keep-getting-undefined-local-variable-or-method-when-creating-a-new-rails-application/151033 "2008-10-16T04:02:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![command0](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a9adbd/32.png) [@command0](https://www.ruby-forum.com/u/command0)\
**Post date:** [October 16, 2008, 4:02am UTC](https://www.ruby-forum.com/t/keep-getting-undefined-local-variable-or-method-when-creating-a-new-rails-application/151033/1 "2008-10-16T04:02:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![command0](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a9adbd/32.png) [@command0](https://www.ruby-forum.com/u/command0)\
**Post date:** [October 16, 2008, 4:21am UTC](https://www.ruby-forum.com/t/keep-getting-undefined-local-variable-or-method-when-creating-a-new-rails-application/151033/2 "2008-10-16T04:21:39Z")

</div>

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 😛

Thanks,

Justin

---

<div class="post-metadata">

**Author:** ![command0](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a9adbd/32.png) [@command0](https://www.ruby-forum.com/u/command0)\
**Post date:** [October 16, 2008, 5:43am UTC](https://www.ruby-forum.com/t/keep-getting-undefined-local-variable-or-method-when-creating-a-new-rails-application/151033/3 "2008-10-16T05:43:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![command0](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a9adbd/32.png) [@command0](https://www.ruby-forum.com/u/command0)\
**Post date:** [October 16, 2008, 2:34pm UTC](https://www.ruby-forum.com/t/keep-getting-undefined-local-variable-or-method-when-creating-a-new-rails-application/151033/4 "2008-10-16T14:34:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![command0](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a9adbd/32.png) [@command0](https://www.ruby-forum.com/u/command0)\
**Post date:** [October 16, 2008, 8:38pm UTC](https://www.ruby-forum.com/t/keep-getting-undefined-local-variable-or-method-when-creating-a-new-rails-application/151033/5 "2008-10-16T20:38:19Z")

</div>

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
