简体   繁体   中英

rails generate scaffold with --migration=false

I have a very large model (say 200 fields), so it isn't very convenient to write them down into the command line.
So I first generate the migration then i did scaffold with:

rails generate scaffold myModel --migrate=false

It generated the controller with its actions, it updated the routes.rb and created views/myModel. But it didn't add the fields to the views. Isn't scaffold supposed to provide a basic field presentation? If not, is there a way to provide it?

Scaffold uses the command line arguments you specify to create the relevant files. If you don't specify any fields at the command line then it can't add them to the views (because it doesn't know them). The Scaffold command is a one time thing. You might consider typing out and/or programmatically creating the relevant scaffold command in a text editor and pasting it into the console.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM