Forum: Ruby on Rails Newbie question - Automatically update _form.rhtml?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Paul S. (Guest)
on 2006-02-27 12:05
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/rail...

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
Łukasz Piestrzeniewicz (Guest)
on 2006-02-27 12:24
(Received via mailing list)
On 27/02/06, Paul S. <removed_email_address@domain.invalid> 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.
Ben M. (Guest)
on 2006-02-27 19:28
(Received via mailing list)
Łukasz Piestrzeniewicz wrote:
> On 27/02/06, Paul S. <removed_email_address@domain.invalid> 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 (Guest)
on 2006-02-27 19:47
(Received via mailing list)
> 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/tut...
--
Juan Lupión (Guest)
on 2006-02-27 19:50
(Received via mailing list)
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 <removed_email_address@domain.invalid> wrote:
>
> Greetings.
>
> [1]. 
http://www.sobrerailes.com/articles/2006/02/24/tut...
> --
> ----------------------------------------------------
> http://www.sobrerailes.com
>


--
Curt H. (Guest)
on 2006-02-28 05:55
(Received via mailing list)
On 2/27/06, Paul S. <removed_email_address@domain.invalid> 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:

  http://www.onlamp.com/onlamp/2005/03/03/examples/c...

Curt
Łukasz Piestrzeniewicz (Guest)
on 2006-02-28 10:32
(Received via mailing list)
On 27/02/06, Ben M. <removed_email_address@domain.invalid> 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
Ben M. (Guest)
on 2006-02-28 18:44
(Received via mailing list)
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
Curt H. (Guest)
on 2006-02-28 22:41
(Received via mailing list)
On 2/28/06, Ben M. <removed_email_address@domain.invalid> 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. :-O

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
This topic is locked and can not be replied to.