Create Ruby on Rails views (only) after controllers and models are already created

后端 未结 6 1065
庸人自扰
庸人自扰 2020-12-23 02:21

I\'ve obtained a project that have controllers (minimal code only) and models, but the views are missing. Is there a way to generate the views only using scaffold or another

6条回答
  •  伪装坚强ぢ
    2020-12-23 03:13

    This is what the scaffold generator calls internally:

    rails g erb:scaffold User
    

    erb is the templating engine used, so you can also use haml:scaffold.

    You must explicitly specify the fields you would like the scaffolding to use--rails does not automatically deduce them from the created model. For example:

    rails g erb:scaffold User firstname lastname reputation
    

    See rails g --help for options like skipping, forcing overwriting, and dry runs or generate scaffold --help for information specific to generating scaffolding.

提交回复
热议问题