I am trying to give administrators of my web application the ability to add some new fields to the model. The model is called Artwork, and I would like to add a test_column column at run time for the instance. I'm just recording, so I added a simple link to do this, it will, of course, be parametric.
I managed to do this through migrations:
def test_migration_create Artwork.add_column :test_column, :integer flash[:notice] = "Added Column test_column to artworks" redirect_to :action => 'index' end def test_migration_delete Artwork.remove_column :test_column flash[:notice] = "Removed column test_column from artworks" redirect_to :action => 'index' end
This works, the column is added / removed to / from the database without problems. I am using active_scaffold at the moment, so I get the test_column field in the form without adding anything. However, when I submit the creation or update, test_column is not updated and remains empty. Checking the parameters, I see:
Parameters: {"commit"=>"Update", "authenticity_token"=>"37Bo5pT2jeoXtyY1HgkEdIhglhz8iQL0i3XAx7vu9H4=", "id"=>"62", "record"=>{"number"=>"test_artwork", "author"=>"", "title"=>"Opera di Test", "test_column"=>"TEEST", "year"=>"", "description"=>""}}
the test_column parameter is passed correctly. So why does the active record continue to ignore it? I also tried restarting the server without success.
I am using ruby 1.8.7, rails 2.3.5 and mongrel with sqlite3 database.
thanks