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

后端 未结 6 1069
庸人自扰
庸人自扰 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条回答
  •  萌比男神i
    2020-12-23 03:10

    I just encounter the same your problem. I did it. More detail is below:
    - First I rename views/your_model folder to views/your_model_bak. In order to revert if fail later
    - Then, execute command

    rails g scaffold YourModel [field[:type][:index]] --skip
    
    • Don't forget --skip option, it will not create exist files (controller and model in this case and few other files)
    • Make sure list [field[:type][:index]] is up to date

    -- Finally, you should update your permit in your_model controller.

    Hope it can help you.

提交回复
热议问题