gpt4 book ai didi

ruby-on-rails - 删除 show 方法及其所有依赖项

转载 作者:行者123 更新时间:2023-12-04 22:37:01 25 4
gpt4 key购买 nike

我有一个由脚手架创建的现有实体。现在我意识到我并不真的需要呈现显示 View ,因此我想消除现在不必要的任何方法和部分。除了在对象 Controller 上为我创建的 show 方法之外,我还应该删除哪些其他部分?这些是我能想到的:

  • 实体
  • show.html.erb 文件
  • link_to 引用 index.html.erbedit.html.erb 文件中的对象实例
  • redirect_to 在 Controller 上调用更新和创建方法

  • 还有什么我应该删除的吗?

    最佳答案

    你应该:

  • 从 Controller 中移除 show Action
  • 切换redirect_tocreate中的update,跳转到新 Action
  • link_toindex.html.erb
  • 中删除 edit.html.erb s
  • 删除app/views/entities/show.html.erb
  • 通过将 config/routes.rb 文件中的 resources :entities 行更改为 resources :entities, :except => :show
  • 来停止生成路由

    关于ruby-on-rails - 删除 show 方法及其所有依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4445010/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com