Hi, I am using scaffolding to create application quickly. I have already created the database and table (there is only one table: products). When I use command: ruby script/generate scaffold Product I get all the scripts generated. When I direct my browser to URL: http://localhost:3000/products I see only the title of the page like ''Listing products'' and a link to create new product. That is obvious as there are no products in the table. But when I follow link to create new product, it should display me a form matching to table columns, isn''t it? But does not show me anything there. What I get is title ''New product'', a button ''Create'' and a ''Back'' link. Can anyone direct me where I am going wrong with this? Or is there anything else needed to do for this? I guess, somehow the rails is not being able to get the table fields. Hence, it is unable to show the form. As it gets empty set of table columns, the form displayed is also empty. Please provide some inputs on this. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Prabhas Gupte wrote:> Hi, > I am using scaffolding to create application quickly. I have already > created the database and table (there is only one table: products). > When I use command: ruby script/generate scaffold Product > I get all the scripts generated. When I direct my browser to URL: > http://localhost:3000/products I see only the title of the page like > ''Listing products'' and a link to create new product. That is obvious > as there are no products in the table. > But when I follow link to create new product, it should display me a > form matching to table columns, isn''t it? But does not show me > anything there. What I get is title ''New product'', a button ''Create'' > and a ''Back'' link. > > Can anyone direct me where I am going wrong with this? Or is there > anything else needed to do for this? > > I guess, somehow the rails is not being able to get the table fields. > Hence, it is unable to show the form. > As it gets empty set of table columns, the form displayed is also > empty. > > Please provide some inputs on this.How did you create your table ? With plain SQL or through migration ? I believe that the scaffold thing loads columns name from your DB to generate dynamic form, that means if a new column appear in your table, a new input will appear as well in your form. But if there is not column, there is no input. Maybe you did not use the migration to create and populate your table and you should look there first. If you did, then I don''t know what''s going wrong. Guillaume http://www.nomadsper.com -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 8 Jul 2008, at 10:00, Guillaume Petit wrote:> How did you create your table ? With plain SQL or through migration ? > > I believe that the scaffold thing loads columns name from your DB to > generate dynamic form, that means if a new column appear in your > table, > a new input will appear as well in your form. But if there is not > column, there is no input. >Not since rails 2 it doesn''t. As of rails 2 if you edit the model then you need to update the form appropriately. Fred> Maybe you did not use the migration to create and populate your table > and you should look there first. If you did, then I don''t know what''s > going wrong. > > Guillaume > http://www.nomadsper.com > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
The 2.x scaffolding no longer looks for or inspects any existing tables. You''ve got to list out the columns & their types on the call to generate. So for example: ruby script/generate scaffold Product name:string source:string date_acquired:date etc. HTH, -Roy -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Prabhas Gupte Sent: Monday, July 07, 2008 9:04 PM To: Ruby on Rails: Talk Cc: gprabhas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Subject: [Rails] Problem with scaffolding? Hi, I am using scaffolding to create application quickly. I have already created the database and table (there is only one table: products). When I use command: ruby script/generate scaffold Product I get all the scripts generated. When I direct my browser to URL: http://localhost:3000/products I see only the title of the page like ''Listing products'' and a link to create new product. That is obvious as there are no products in the table. But when I follow link to create new product, it should display me a form matching to table columns, isn''t it? But does not show me anything there. What I get is title ''New product'', a button ''Create'' and a ''Back'' link. Can anyone direct me where I am going wrong with this? Or is there anything else needed to do for this? I guess, somehow the rails is not being able to get the table fields. Hence, it is unable to show the form. As it gets empty set of table columns, the form displayed is also empty. Please provide some inputs on this. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thank you very much for your replies! @ Guillaume I have tried both the ways: creating table using migration and using SQL as well. @ Fred Are you sure it doen''t work like I expected since rails 2.x? Or were you talking about updations to model. What if I do not update the model? will it give me the form for the first time? @ Roy Does it mean that I need to list all the fields and their types in field:type format in the generate command itself? On Jul 8, 8:27 pm, "Pardee, Roy" <parde...-go57ItdSaco@public.gmane.org> wrote:> The 2.x scaffolding no longer looks for or inspects any existing tables. > You''ve got to list out the columns & their types on the call to > generate. So for example: > > ruby script/generate scaffold Product name:string source:string > date_acquired:date > > etc. > > HTH, > > -Roy > > -----Original Message----- > From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Prabhas Gupte > Sent: Monday, July 07, 2008 9:04 PM > To: Ruby on Rails: Talk > Cc: gprab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > Subject: [Rails] Problem with scaffolding? > > Hi, > I am using scaffolding to create application quickly. I have already > created the database and table (there is only one table: products). > When I use command: ruby script/generate scaffold Product I get all the > scripts generated. When I direct my browser to URL:http://localhost:3000/productsI see only the title of the page like > ''Listing products'' and a link to create new product. That is obvious as > there are no products in the table. > But when I follow link to create new product, it should display me a > form matching to table columns, isn''t it? But does not show me anything > there. What I get is title ''New product'', a button ''Create'' > and a ''Back'' link. > > Can anyone direct me where I am going wrong with this? Or is there > anything else needed to do for this? > > I guess, somehow the rails is not being able to get the table fields. > Hence, it is unable to show the form. > As it gets empty set of table columns, the form displayed is also empty. > > Please provide some inputs on this.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Well, you need to list out all the fields you want to show up on your forms. If you miss any, you can always add them in manually of course. Here''s a past thread where I beat this to death: http://is.gd/P3t HTH, -Roy -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Prabhas Gupte Sent: Tuesday, July 08, 2008 7:21 PM To: Ruby on Rails: Talk Subject: [Rails] Re: Problem with scaffolding? Thank you very much for your replies! @ Guillaume I have tried both the ways: creating table using migration and using SQL as well. @ Fred Are you sure it doen''t work like I expected since rails 2.x? Or were you talking about updations to model. What if I do not update the model? will it give me the form for the first time? @ Roy Does it mean that I need to list all the fields and their types in field:type format in the generate command itself? On Jul 8, 8:27 pm, "Pardee, Roy" <parde...-go57ItdSaco@public.gmane.org> wrote:> The 2.x scaffolding no longer looks for or inspects any existingtables.> You''ve got to list out the columns & their types on the call to > generate. So for example: > > ruby script/generate scaffold Product name:string source:string > date_acquired:date > > etc. > > HTH, > > -Roy > > -----Original Message----- > From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Prabhas Gupte > Sent: Monday, July 07, 2008 9:04 PM > To: Ruby on Rails: Talk > Cc: gprab...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > Subject: [Rails] Problem with scaffolding? > > Hi, > I am using scaffolding to create application quickly. I have already > created the database and table (there is only one table: products). > When I use command: ruby script/generate scaffold Product I get all > the scripts generated. When I direct my browser to > URL:http://localhost:3000/productsI see only the title of the page > like ''Listing products'' and a link to create new product. That isobvious as there are no products in the table.> But when I follow link to create new product, it should display me a > form matching to table columns, isn''t it? But does not show me > anything there. What I get is title ''New product'', a button ''Create'' > and a ''Back'' link. > > Can anyone direct me where I am going wrong with this? Or is there > anything else needed to do for this? > > I guess, somehow the rails is not being able to get the table fields. > Hence, it is unable to show the form. > As it gets empty set of table columns, the form displayed is alsoempty.> > Please provide some inputs on this.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---