I have run the command
rails g scaffold article
and forget get to pass column name now how can i add column to my article
table.
CodePudding user response:
You can either
undo your scaffold with
rails d scaffold article
(cf. https://www.rubyguides.com/2020/03/rails-scaffolding/) and re-do it with the missing field,or you can run a migration afterwards to add the missing column to your article table:
rails g migration add_title_to_article article:string
CodePudding user response:
You can just add your column with a new migration. You run the migration with the name of column you want to adds and then declare the data type after the migration command. The command to add name is as below:
rails g migration AddNameToArticle name:string
This can also be done as @Guilaume Bihet stated.
rails g migration add_name_to_article name:string