command0
2008-Oct-15 21:57 UTC
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:integerAnd 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
command0
2008-Oct-15 22:07 UTC
Re: Keep getting "Undefined local variable or method" when creating a new rails application
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 On Oct 15, 3:57 pm, command0 <justinbrinkerh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Oct-15 23:29 UTC
Re: Keep getting "Undefined local variable or method" when creating a new rails application
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Pardee, Roy
2008-Oct-16 12:33 UTC
Re: Keep getting "Undefined local variable or method" when creating a new rails application
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 -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk@googlegroups.com] On Behalf Of command0 Sent: Wednesday, October 15, 2008 3:07 PM To: Ruby on Rails: Talk Subject: [Rails] Re: Keep getting "Undefined local variable or method" when creating a new rails application 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 On Oct 15, 3:57 pm, command0 <justinbrinkerh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
command0
2008-Oct-16 18:37 UTC
Re: Keep getting "Undefined local variable or method" when creating a new rails application
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 On Oct 16, 6:33 am, "Pardee, Roy" <parde...-go57ItdSaco@public.gmane.org> wrote:> 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 > > -----Original Message----- > From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk@googlegroups.com] On Behalf Of command0 > Sent: Wednesday, October 15, 2008 3:07 PM > To: Ruby on Rails: Talk > Subject: [Rails] Re: Keep getting "Undefined local variable or method" when creating a new rails application > > 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 > > On Oct 15, 3:57 pm, command0 <justinbrinkerh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---