Rails ActiveAdmin - 编辑所有新操作
Rails ActiveAdmin - edit all new actions
我需要覆盖 AA 中多个模型的所有 new
操作。目前我正在一个一个地覆盖模型,所以我有很多重复的代码。
如何一次编辑所有新动作?
为了提供一些背景知识,我在每个 AA 资源文件中都这样做:
controller do
def new
# things
end
end
你应该创建一个模块并在该模块中编写你的方法,然后在每个控制器中包含该模块
class YourController < ApplicationController
include YourControllerConcern
# rest of the controller codes
end
但请阅读 ,其中包含更多信息
而如果您从未使用过 include
这是 good explanation of what it does and this is a complete guide about include
and extend
我需要覆盖 AA 中多个模型的所有 new
操作。目前我正在一个一个地覆盖模型,所以我有很多重复的代码。
如何一次编辑所有新动作?
为了提供一些背景知识,我在每个 AA 资源文件中都这样做:
controller do
def new
# things
end
end
你应该创建一个模块并在该模块中编写你的方法,然后在每个控制器中包含该模块
class YourController < ApplicationController
include YourControllerConcern
# rest of the controller codes
end
但请阅读
而如果您从未使用过 include
这是 good explanation of what it does and this is a complete guide about include
and extend