Paul Sweeney
2006-Feb-27 10:06 UTC
[Rails] Newbie question - Automatically update _form.rhtml?
Hi all, I''ve got an odd issue. I''m new to Ruby/Rails and have a bit of a silly question. I''m following along with the nice little tutorial here, to get an idea of the system: http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html?page=3 However, I''m running into an issue where the author adds a new field in his database, refreshes the browser and shows the updated form with the new field. Okay, maybe I''m missing something, but I can''t, for the life of me, figure out how this is done. I''ve actually poked the system enough to realise that the _form.rhtml file is controlling this snipped, and that it''s not updating when I update my database. Am I missing something here, or do I have to manually regenerate _form.rhtml on database updates? I''m running the newest Rails/Ruby (downloaded last week) on Lighttpd on my Gentoo Linux system. Any ideas? Cheers -- Posted via http://www.ruby-forum.com/.
Łukasz Piestrzeniewicz
2006-Feb-27 10:21 UTC
[Rails] Newbie question - Automatically update _form.rhtml?
On 27/02/06, Paul Sweeney <psweeney@8-bitdesign.com> wrote:> Am I missing something here, or do I have to manually regenerate > _form.rhtml on database updates?You should consider a scaffold-generated files only as an example and customize them as soon as needed. You may regenerate them when database changes - but only during learning or in VERY early stage of development. Later on you have to and should adjust them manually. -- ?ukasz Piestrzeniewicz
Ben Munat
2006-Feb-27 17:26 UTC
[Rails] Newbie question - Automatically update _form.rhtml?
?ukasz Piestrzeniewicz wrote:> On 27/02/06, Paul Sweeney <psweeney@8-bitdesign.com> wrote: > >>Am I missing something here, or do I have to manually regenerate >>_form.rhtml on database updates? > > > You should consider a scaffold-generated files only as an example and > customize them as soon as needed. You may regenerate them when > database changes - but only during learning or in VERY early stage of > development. Later on you have to and should adjust them manually.?ukasz I think you kind of bounced off the side of Paul''s question... he''s still learning and should be fine using scaffold for that. Paul, I think that tutorial might be out of date now and was written back when the scaffolded form introspected the fields in your table on every request. At least I *think* it once did that... But if you look at a _form.rhtml now it just has a generated input field for each column in your db. I think you need to regenerate it to see changes. Someone please correct me if I''m wrong... Curt, you lurking about? b
Juan Lupión
2006-Feb-27 17:47 UTC
[Rails] Newbie question - Automatically update _form.rhtml?
> Someone please correct me if I''m wrong... Curt, you lurking about?Well, I followed Curt''s tutorial last week installing the latest revisions of everything (Ruby, Rails and friends) and had no problems whatsoever. (Just in case anyone''s interested, there is a spanish translation available here [1]) So my bet would be that there''s something wrong with Paul''s setup (Curt''s tutorial uses Windows+WEBrick while he is using Gentoo+lightty)... but I''m clueless... Greetings. [1]. http://www.sobrerailes.com/articles/2006/02/24/tutorial-en-catellano-rolling-with-ruby-on-rails -- ---------------------------------------------------- http://www.sobrerailes.com
Juan Lupión
2006-Feb-27 17:49 UTC
[Rails] Newbie question - Automatically update _form.rhtml?
Just wondering... did you run script/generate scaffold? Then the generated files won''t reflect your changes to the database anyway. On 2/27/06, Juan Lupi?n <pantulis@gmail.com> wrote:> > Someone please correct me if I''m wrong... Curt, you lurking about? > > Well, I followed Curt''s tutorial last week installing the latest > revisions of everything (Ruby, Rails and friends) and had no problems > whatsoever. (Just in case anyone''s interested, there is a spanish > translation available here [1]) > > So my bet would be that there''s something wrong with Paul''s setup > (Curt''s tutorial uses Windows+WEBrick while he is using > Gentoo+lightty)... but I''m clueless... > > Greetings. > > [1]. http://www.sobrerailes.com/articles/2006/02/24/tutorial-en-catellano-rolling-with-ruby-on-rails > -- > ---------------------------------------------------- > http://www.sobrerailes.com >-- ---------------------------------------------------- http://hronia.blogalia.com
Curt Hibbs
2006-Feb-28 03:54 UTC
[Rails] Newbie question - Automatically update _form.rhtml?
On 2/27/06, Paul Sweeney <psweeney@8-bitdesign.com> wrote:> Hi all, I''ve got an odd issue. I''m new to Ruby/Rails and have a bit of a > silly question. I''m following along with the nice little tutorial here, > to get an idea of the system: > > http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html?page=3 > > However, I''m running into an issue where the author adds a new field in > his database, refreshes the browser and shows the updated form with the > new field. > > Okay, maybe I''m missing something, but I can''t, for the life of me, > figure out how this is done. I''ve actually poked the system enough to > realise that the _form.rhtml file is controlling this snipped, and that > it''s not updating when I update my database. > > Am I missing something here, or do I have to manually regenerate > _form.rhtml on database updates? > > I''m running the newest Rails/Ruby (downloaded last week) on Lighttpd on > my Gentoo Linux system. Any ideas?If you followed the tutorial, then there shouldn''t even be a _form.rhtml, because the tutorial usues dynamic scaffolding that does not generate any code (there''s another kind of scaffolding created with the "script/generate scaffold" command that does create code filles, but the tutorial does not use this). You can download the source code for the cookbook app and compare it with yours to see what''s different: http://www.onlamp.com/onlamp/2005/03/03/examples/cookbook_part2_0.13.1.zip Curt
Łukasz Piestrzeniewicz
2006-Feb-28 08:31 UTC
[Rails] Newbie question - Automatically update _form.rhtml?
On 27/02/06, Ben Munat <bent@munat.com> wrote:> ?ukasz I think you kind of bounced off the side of Paul''s question... he''s still learning > and should be fine using scaffold for that.I strongly disagree. Curt''s tutorial was a very valuable resource. Was - a year ago. During this year Rails evolved. Now I consider this material more harmfull than helpfull. It just teaches too many bad habits. Adding fields to the database through clickety-clik? Using run-time scaffold instead of generated one? Right now Apple''s tutorial is a lot better resource: http://developer.apple.com/tools/rubyonrails.html -- ?ukasz Piestrzeniewicz http://ragnarson.blogspot.com
Ben Munat
2006-Feb-28 16:43 UTC
[Rails] Newbie question - Automatically update _form.rhtml?
Ok. Fair enough. I just didn''t see your answer answering his question... of course, I didn''t really help much either. ;-) Curt, I think ?ukasz is calling you out. :-O b ?ukasz Piestrzeniewicz wrote:> On 27/02/06, Ben Munat <bent@munat.com> wrote: > >>?ukasz I think you kind of bounced off the side of Paul''s question... he''s still learning >>and should be fine using scaffold for that. > > > I strongly disagree. Curt''s tutorial was a very valuable resource. Was > - a year ago. During this year Rails evolved. Now I consider this > material more harmfull than helpfull. It just teaches too many bad > habits. Adding fields to the database through clickety-clik? Using > run-time scaffold instead of generated one? > > Right now Apple''s tutorial is a lot better resource: > http://developer.apple.com/tools/rubyonrails.html > > -- > ?ukasz Piestrzeniewicz > http://ragnarson.blogspot.com > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Curt Hibbs
2006-Feb-28 20:41 UTC
[Rails] Newbie question - Automatically update _form.rhtml?
On 2/28/06, Ben Munat <bent@munat.com> wrote:> Ok. Fair enough. I just didn''t see your answer answering his question... of course, I > didn''t really help much either. ;-) > > Curt, I think ?ukasz is calling you out. :-OI basically agree. A lot has changed in Rails in the last year (boy is that an understatement). Migrations are the way to go for real database work, although I see nothing wrong with GUI DB development for someone who whose testing the waters. I actually intended it to be an intro for Windows developers because (at the time) there was already plenty of material available for Linux & OSX. Because of this I deliberately took a very visual style. Curt