简体   繁体   English

如何在ActiveAdmin的仪表板中使用参数?

[英]How can I use parameters in the ActiveAdmin's dashboard?

I'm showing a lot of graphs and aggregated data in the ActiveAdmin's dashboard, but I would like to make it more flexible for the user, so after a lot of work I made a form in the dashboard using a partial where the user can choose a date range and other options. 我在ActiveAdmin的仪表板中显示了许多图形和汇总数据,但我想使其对用户更加灵活,因此在完成大量工作之后,我在仪表板中使用了一部分表格,用户可以在其中选择一个表格日期范围和其他选项。 These parameters should be used to filter the data shown in ActiveAdmin's dashboard... 这些参数应用于过滤ActiveAdmin仪表板中显示的数据...

The problem is I discovered I can't access to the params method in an ActiveAdmin register_page . 问题是我发现我无法访问ActiveAdmin register_pageparams方法。 The exact error I'm getting is the following: undefined local variable or method 'params' for #<ActiveAdmin::PageDSL:0x005585abf414c0> 我得到的确切错误如下: undefined local variable or method 'params' for #<ActiveAdmin::PageDSL:0x005585abf414c0>

So, is there a way to fix this? 那么,有没有办法解决这个问题? The only thing I'm capable of think is to execute another controller/action to save the data submited by the user in the form directly into the database and then redirect the user to the ActiveAdmin's dashboard. 我唯一能想到的就是执行另一个控制器/操作,将用户以表格形式提交的数据直接保存到数据库中,然后将用户重定向到ActiveAdmin的仪表板。 Finally I would use that data saved in the database to filter what should I show in the Dashboard, but I think it's not a good practice to use the database to pass parameters ... Any ideas? 最后,我将使用保存在数据库中的数据来过滤应该在仪表板中显示的内容, 但是我认为使用数据库传递参数不是一个好习惯 ……有什么想法吗? What can I do? 我能做什么?

This does show the params: 这确实显示了参数:

ActiveAdmin.register_page "Dashboard" do
  menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
  content title: proc{ I18n.t("active_admin.dashboard") } do
    columns do
      column do
        panel 'Params' do
          params.inspect
        end
      end
    end
 end

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

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