Reputation: 281
It all seemed to work fine in the beginning...
rails generate migration add_starting_date_to_announcements starting_date:date
invoke active_record
create db/migrate/20120106223124_add_starting_date_to_announcements.rb
then
rake db:migrate
== AddStartingDateToAnnouncements: migrating =================================
-- add_column(:announcements, :starting_date, :date)
-> 0.3281s
== AddStartingDateToAnnouncements: migrated (0.3281s) ========================
When I look at the database structure I see starting_date being displayed. The problem is when I hit "new announcement" it shows me the view that contains all the old columns in the database (Text field for "Announcements" and field for "Notes") - but doesn't display the option to use "Starting Date" in the view. It is just not there.
Restarting webrick doesn't help.
Any ideas would be much appreciated. Thanks.
Upvotes: 0
Views: 96
Reputation: 14944
Your DbMigrate is not gonna update your views for you, You'll have to manually go and update those.
And it's doing this for a good reason, imagine you customized your views then went an added another column to your table, do you want your view to be overwritten?
Upvotes: 1
Reputation: 106027
Migrations do not alter your views. You'll either need to add the attribute to the view manually or, if you're relying on scaffolds (which will only get you so far), regenerate them.
Upvotes: 2
Reputation: 230346
After you create and run a migration, you also have to alter your views to add controls for that new column (a simple label for show
view, date_select
for edit
view, etc.)
Ruby and Rails are not that magical to do this for you.
Upvotes: 2