user1263409
user1263409

Reputation: 13

render 'form' not showing columns added using a migration

Initially I ran rails g scaffold Post title:string content:text and after migrating everything worked fine.

However, later on I decided to add a tags column, so I did rails g migration AddTagsToPosts tags:string and rake db:migrate.

Although the output from those commands seemed normal, the /posts/new page still only shows the initial two fields, title and content. The same goes for /posts/x/show and /posts/x/edit. The view file itself only contains render 'form', so apparently I missed something here?

Do I have to run any additional commands to add the new fields to the forms?

Just starting to get into Rails, and this particular issue is pretty hard to google so I figured I'd ask the question here.

Upvotes: 1

Views: 747

Answers (3)

Subtonix
Subtonix

Reputation: 117

Try restarting your rails server and rails console. Worked for me.

Upvotes: 0

gayavat
gayavat

Reputation: 19398

Form partial isn't updated automatically after migration. You should manually add new fields to _form.html.erb

Upvotes: 2

Waynn Lue
Waynn Lue

Reputation: 11375

Adding the migration doesn't change the views that were creating by generating the scaffold. So you either need to re-run the generation for the scaffold, or just manually edit the _form file to add the new columns.

Upvotes: 3

Related Questions