So I created the following MYSQL table CREATE TABLE contacts ( id int AUTO_INCREMENT NOT NULL, firstname varchar(50) NULL, lastname varchar(50) NULL, prefix_id int NULL, email varchar(100) NULL, phone varchar(50) NULL, fax varchar(25) NOT NULL ) and tied to a controller called Contacts which can be accessed at http://kbcexpenses.railsapphosting.com/contacts/. When you go to that page you''ll see the following: Listing contacts Firstname Lastname Email Phone Fax Rob Nam name-J0of1frlU80@public.gmane.org 212-888-8888 212-888-8888 Show Edit Destroy Kris Nomen name-J0of1frlU80@public.gmane.org 212-888-8888 212-888-8888 Show Edit Destroy Dirk Small Name name-J0of1frlU80@public.gmane.org 212-888-8888 212-888-8888 Show Edit Destroy Christopher Name name-J0of1frlU80@public.gmane.org 212-888-8888 212-888-8888 Show Edit Destroy New contacts The key thing to notice is that there are five columns of data properly displayed which show data in five of the seven fields in the contacts table. However, when I click on the Edit button (see that it takes you to: http://kbcexpenses.railsapphosting.com/contacts/edit/1) I am only able to edit the following three fields firstname lastname email I should also be able to edit the phone and fax numbers. I created this edit.rhtml file using the generate scaffold command from Rails. Can anyone tell me why I am only able to edit certain fields and not others. Thanks for your help, Rasheq _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
> However, when I click on the Edit button (see that it takes you to: > http://kbcexpenses.railsapphosting.com/contacts/edit/1) > > I am only able to edit the following three fields > > firstname > lastname > email > > I should also be able to edit the phone and fax numbers. > > I created this edit.rhtml file using the generate scaffold command from > Rails. >Is it possible that you generated the scaffold code before adding those fields? The scaffold code does not add new fields, you''ll have to regenerate the scaffold or add the new fields yourself. The list view loops through the column names, so it recognizes new columns on the fly IIRC. -- rick http://techno-weenie.net
I did actually run the scaffold before adding the phone and email fields. How do I go about adding the fields? Why is it that part of the scaffold ( i.e. the list method) recognizes the new fields and another part (i.e the edit method) doesn''t? Rasheq On 8/9/05, Rick Olson <technoweenie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > However, when I click on the Edit button (see that it takes you to: > > http://kbcexpenses.railsapphosting.com/contacts/edit/1) > > > > I am only able to edit the following three fields > > > > firstname > > lastname > > email > > > > I should also be able to edit the phone and fax numbers. > > > > I created this edit.rhtml file using the generate scaffold command from > > Rails. > > > > Is it possible that you generated the scaffold code before adding > those fields? The scaffold code does not add new fields, you''ll have > to regenerate the scaffold or add the new fields yourself. The list > view loops through the column names, so it recognizes new columns on > the fly IIRC. > > -- > rick > http://techno-weenie.net > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Rasheq Rahman wrote:> I did actually run the scaffold before adding the phone and email > fields. How do I go about adding the fields? Why is it that part of the > scaffold (i.e. the list method) recognizes the new fields and another > part (i.e the edit method) doesn''t?Just run the scaffold script again and let it overwrite the old files. If you want completely dynamic scaffolding that will always pick up new fields, then instead of running the scaffold script to physically generate the files, just generate the controller: ruby script/generate controller contacts and add the scaffold directive to the generated controller class: scaffold :contacts Curt> Rasheq > > On 8/9/05, *Rick Olson* <technoweenie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > <mailto:technoweenie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote: > > > However, when I click on the Edit button (see that it takes you to: > > http://kbcexpenses.railsapphosting.com/contacts/edit/1) > > > > I am only able to edit the following three fields > > > > firstname > > lastname > > email > > > > I should also be able to edit the phone and fax numbers. > > > > I created this edit.rhtml file using the generate scaffold > command from > > Rails. > > > > Is it possible that you generated the scaffold code before adding > those fields? The scaffold code does not add new fields, you''ll have > to regenerate the scaffold or add the new fields yourself. The list > view loops through the column names, so it recognizes new columns on > the fly IIRC. > > -- > rick > http://techno-weenie.net > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Thanks all. I ended up recreating the app and using the scaffold directive instead of the scaffold generator. As suggested it was more appropriate for what I was aiming to do. Rasheq On Aug 9, 2005, at 3:03 PM, Curt Hibbs wrote:> Rasheq Rahman wrote: > >> I did actually run the scaffold before adding the phone and email >> fields. How do I go about adding the fields? Why is it that part >> of the scaffold (i.e. the list method) recognizes the new fields >> and another part (i.e the edit method) doesn''t? >> > > Just run the scaffold script again and let it overwrite the old files. > > If you want completely dynamic scaffolding that will always pick up > new fields, then instead of running the scaffold script to > physically generate the files, just generate the controller: > > ruby script/generate controller contacts > > and add the scaffold directive to the generated controller class: > > scaffold :contacts > > Curt > > > >> Rasheq >> On 8/9/05, *Rick Olson* <technoweenie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >> <mailto:technoweenie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote: >> > However, when I click on the Edit button (see that it >> takes you to: >> > http://kbcexpenses.railsapphosting.com/contacts/edit/1) >> > >> > I am only able to edit the following three fields >> > >> > firstname >> > lastname >> > email >> > >> > I should also be able to edit the phone and fax numbers. >> > >> > I created this edit.rhtml file using the generate scaffold >> command from >> > Rails. >> > >> Is it possible that you generated the scaffold code before adding >> those fields? The scaffold code does not add new fields, >> you''ll have >> to regenerate the scaffold or add the new fields yourself. The >> list >> view loops through the column names, so it recognizes new >> columns on >> the fly IIRC. >> -- >> rick >> http://techno-weenie.net >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> >> http://lists.rubyonrails.org/mailman/listinfo/rails >> --------------------------------------------------------------------- >> --- >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >