travis michel
2006-Apr-04 09:52 UTC
[Rails] small question about the relevance of the "database schema has changed"
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 Walton
2006-Apr-04 12:58 UTC
[Rails] small question about the relevance of the "database schemahas changed"
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 Koppelman
2006-Apr-04 13:36 UTC
[Rails] Re: small question about the relevance of the "database sche
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.-- Posted via http://www.ruby-forum.com/.
Steve Odom
2006-Apr-04 13:55 UTC
[Rails] small question about the relevance of the "database schema has changed"
This sounds like a migrations solution. Steve http://www.smarkets.net On 4/4/06, travis michel <meshac.ruby@gmail.com> 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. > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060404/a9ded6ec/attachment.html