RAILS:在更改基础表之后,如何再生脚手架创造的所有观点?
Rails的新手,所以请随时编辑我的问题,如果术语错了!
我已经通过脚手架创建了我的MVC,但此后已更改了基础表(重命名了一些列,添加了一些列)。有没有一种方法可以再生用原始脚手架创建的观点以反映我所做的更改?
如果我运行rails g脚手架foo -migration = false -skip
我会发现我的模型名称已经在我的应用程序中使用了。
如果删除了整个相应的视图文件夹(由原始支架创建的文件夹),并且我运行rails g脚手架foo -migration = false -force -force
生成的视图仍然不会拾取所有我在模型中拥有的字段。
New to Rails, so please feel free to edit my question should I get the terminology wrong!
I've created my MVC via scaffold, but have since made changes to the underlying table (renamed some columns, added some columns). Is there a way to regenerate the views that were created with the original scaffold such that they reflect the changes I've made?
If I run rails g scaffold Foo --migration=false --skip
I get an error that my model name is already used in my application.
If delete the entire corresponding views folder (the one created by the original scaffold), and I run rails g scaffold Foo --migration=false --force
the views generated still don't pick up all the fields I have in my model.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以扭转脚手架的一代,并重新生成一个新的脚手架,并重命名为新的专栏。
如果您已经迁移了数据库,则需要将其滚回去。
然后,您可以扭转脚手架的一代。
然后,使用更新的列生成新的脚手架,
否则您可以手动重写视图和控制器,以包括更新的列和新列。
You could reverse the scaffold generation and regenerate a new scaffold with renamed and new columns.
If you already migrated the database you will need to roll it back.
Then you can reverse the scaffold generation.
Then generate new scaffold with updated columns
Otherwise you can manually rewrite your views and controllers to include the updated and new columns.