This is a real newbie question with what i''m sure will be a simple answer... If i add a column a table (in a development application), how do i update my models to reflect this change? Cheers, Steve
Stephen Bartholomew wrote:> This is a real newbie question with what i''m sure will be a simple > answer... > > If i add a column a table (in a development application), how do i > update my models to reflect this change?Hi STeve, You don''t actually have to update your models. If you look insde the model code, you''ll see it''s empty :-) You *may* have to update the views/forms etc that the scaffold generated. Unfortunately there''s no way to ncrementally do this, you just have to destroy, then re-generate the scaffold (or just add the field by hand). Alan -- Posted via http://www.ruby-forum.com/.
On 4/26/06, Stephen Bartholomew <sb@2404.co.uk> wrote:> This is a real newbie question with what i''m sure will be a simple answer... > > If i add a column a table (in a development application), how do i > update my models to reflect this change? > > Cheers, > > SteveIt will happen automatically. Your models determine which attributes they have from the database on their own. In development mode, that will happen every time a page loads. In production, you need to restart the app.
If there''s nothing special your model needs to do with the column, you don''t have to do anything. In development mode, your application will be magically aware of the new field instantly. If there''s something your model needs to know about the field, like a foreign-key relationship (belongs_to, has_many, etc.) or an attr_accessor declaration or something like that, then you put that in your model and you''re all set. In production mode, when you make changes like this, you need to restart the application, either by restrting the webserver or restarting any FCGI processes, depending on your production environment. Stephen Bartholomew wrote:> This is a real newbie question with what i''m sure will be a simple > answer... > > If i add a column a table (in a development application), how do i > update my models to reflect this change? > > Cheers, > > Steve-- Posted via http://www.ruby-forum.com/.
That''s embarrassingly simple :0) Cheers, Steve Wilson Bilkovich wrote:> On 4/26/06, Stephen Bartholomew <sb@2404.co.uk> wrote: > >>This is a real newbie question with what i''m sure will be a simple answer... >> >>If i add a column a table (in a development application), how do i >>update my models to reflect this change? >> >>Cheers, >> >>Steve > > > It will happen automatically. Your models determine which attributes > they have from the database on their own. > In development mode, that will happen every time a page loads. In > production, you need to restart the app. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >