Forum: Ruby on Rails small question about the relevance of the "database schema h

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.
travis michel (Guest)
on 2006-04-04 13:52
(Received via mailing list)
I have developed 3 small applications using rails (nothing production
worthy, just some small stuff "prototype" style).  And I often end up
changing my database scheme in the middle of development.  I also use
"script/generate scaffold" (this is somehow relevant to my question).
Whenever I change my database schema I end up having to regenerate the
scaffold.  In the past this was okay, because I would not choose to
overwrite files that I have worked on; but this raises a question....
why does rails care if I change the schema?
Effectively, the last time I regenerated the scaffolding I overwrote
nothing; as far as I can tell, as an application developer, nothing
changed between the time that I got the classic error of "database
schema has changed" to now when the application works as I expect it.

I'm just wondering if this is some protection against developers who
don't know wtf (like me) or if this is some out of date annoyance.

sincerely, (and with much love too ;)
travis michel.
Bill W. (Guest)
on 2006-04-04 16:58
(Received via mailing list)
Hi Travis,

travis michel wrote:
<snip>
> Whenever I change my database schema I
> end up having to regenerate the scaffold.

Without knowing the particulars of your situation I can't say for sure
but,
in many circumstances, a change in the db schema would not require the
regen
of the scaffold, only of the model.  That won't touch any of your view
or
controller code.

ruby script\generate model ModelName

HTH,
Bill
Steve K. (Guest)
on 2006-04-04 17:35
Usually once you've generated your models and other scaffolds for a
given table or object, you almost never regenerate them again unless
you're in very early stages of working with a table and you've decided
to wipe it out and start from scratch. You make any necessary subsequent
changes by hand, because by that point you should already be customizing
your views, models and controllers, and generating again would wipe out
all your own code.

Scaffolding and generators in general are just for creating an initial
skeleton for parts of your app. It is intended simply as a quick way to
generate the files and directories a model or controller generally need.
From there on, as you add fields to existing parts of your db schema,
you add whatever code you need to your views (which you rewrite from
scratch once you really start working on the app), you add relations,
validations and other stuff like that to your models, you add more
views, and so on, by hand.

travis michel wrote:
> I have developed 3 small applications using rails (nothing production
> worthy, just some small stuff "prototype" style).  And I often end up
> changing my database scheme in the middle of development.  I also use
> "script/generate scaffold" (this is somehow relevant to my question).
> Whenever I change my database schema I end up having to regenerate the
> scaffold.  In the past this was okay, because I would not choose to
> overwrite files that I have worked on; but this raises a question....
> why does rails care if I change the schema?
> Effectively, the last time I regenerated the scaffolding I overwrote
> nothing; as far as I can tell, as an application developer, nothing
> changed between the time that I got the classic error of "database
> schema has changed" to now when the application works as I expect it.
>
> I'm just wondering if this is some protection against developers who
> don't know wtf (like me) or if this is some out of date annoyance.
>
> sincerely, (and with much love too ;)
> travis michel.
Steve O. (Guest)
on 2006-04-04 17:57
(Received via mailing list)
This sounds like a migrations solution.

Steve
http://www.smarkets.net
This topic is locked and can not be replied to.