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:

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

On 27/02/06, Paul S. [email protected] 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 wrote:

On 27/02/06, Paul S. [email protected] 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

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 [email protected] wrote:

Greetings.

[1]. http://www.sobrerailes.com/articles/2006/02/24/tutorial-en-catellano-rolling-with-ruby-on-rails


http://www.sobrerailes.com

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

On 27/02/06, Ben M. [email protected] 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

Ok. Fair enough. I just didn’t see your answer answering his question…
of course, I
didn’t really help much either. :wink:

Curt, I think Łukasz is calling you out. :open_mouth:

b

On 2/28/06, Ben M. [email protected] wrote:

Ok. Fair enough. I just didn’t see your answer answering his question… of course, I
didn’t really help much either. :wink:

Curt, I think Łukasz is calling you out. :open_mouth:

I 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

On 2/27/06, Paul S. [email protected] wrote:

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:

Radar – O’Reilly

Curt