简体   繁体   English

如何使用活动管理员在同一页面上显示多个模型的数据?

[英]How to show data from multiple models on the same page with active admin?

I am using active admin gem. 我正在使用主动管理工具。 In my database there are two tables: lists and items . 在我的数据库中,有两个表: listsitems I added the model lists to active admin. 我将模型lists添加到活动管理员。 My goal is when I use the basic actions (new, show, update), I should be able immediately work with the data list and it's items on one page. 我的目标是当我使用基本操作(新功能,显示功能,更新功能)时,我应该能够立即处理数据列表及其项,并将它们放在一页上。 Can someone explain how to do that? 有人可以解释该怎么做吗?

Active admin has a super version of the methods you want to intercept in which case you can define them and then call their parent and in the block you have access to the instance variable already created for you and you can use to perform operations on it and associate records. 活动管理员具有您要拦截的方法的超级版本,在这种情况下,您可以定义它们,然后调用它们的父对象,并且在该块中,您可以访问已为您创建的实例变量,并且可以用来对它执行操作,并且关联记录。

ActiveAdmin.register List do
  controller do
    def create
      create! do |format|
        @list
      end
    end

    update
      update! do |format|
        @list
      end
    end

    def edit
      edit!
    end
  end
end

Hope this leads you in the right direction. 希望这会指引您正确的方向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM