错误未定义的方法`TO_KEY'[XXX]:尝试使用主动联系table_for阵列数据时,阵列(Rails的,PostgreSQL中,postgres_ext宝石) [英] Error undefined method `to_key' for [xxx] :Array when trying to use array data on Active Admin table_for (Rails, Postgresql, postgres_ext gem)

查看:122
本文介绍了错误未定义的方法`TO_KEY'[XXX]:尝试使用主动联系table_for阵列数据时,阵列(Rails的,PostgreSQL中,postgres_ext宝石)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有使用我设法让数组的数组里面把他们的表(table_for)里面对我的主动管理

I'd like to have use the data I manage to get inside an array of array to put them inside a table(table_for) on one of my Dashboards on Active Admin

我的应用程序是专为学习on Rails的Ruby的更多。一个每日交易应用

My app is a Daily Deal app built to learn more Ruby on Rails.

感谢帮助的话,我现在设法得到所有我需要一个阵列中的数据:
<一href=\"http://stackoverflow.com/questions/20720155/count-occurrence-of-values-in-a-serialized-attributearray-in-active-admin-dash/20722512?noredirect=1#20722512\">Count值出现在Active管理仪表板序列化的属性(数组)(Rails中,主动管理1.0,PostgreSQL数据库,postgres_ext宝石)

Thanks to help on SO, I now manage to get all the data i need inside an Array: Count occurrence of values in a serialized attribute(array) in Active Admin dashboard (Rails, Active admin 1.0, Postgresql database, postgres_ext gem)

我想用看起来像阵列的数据(它实际上是数组的数组)

The array's data I want to use looks like (it's actually an array of array)

但我想的东西看起来像下面的图片,所以我要使用Active管理员的table_for(将所有的导出功能以后):

But what i'd like is something looking like the image below, so i want to use Active Admin's table_for (to have all the export features later on):

我的仪表盘页面上我现在的code是

My current code on my Dashboard page is

columns do 

  column do

    data = Deal.connection.select_rows(
        %q{ with expanded_deals(id, goal) as (
        select id, unnest(deal_main_goal)
        from deals)

        select goal, count(*) n
        from expanded_deals
        group by goal
        order by goal; }).each do |row|
        goal = row.first
        n    = row.last.to_i
        #....
      end

    panel "Top Goals" do

      table_for data do
          #code
      end

    end  

  end
end  

即使没有施加任何code table_for数据里面,我已经得到的错误:

Even without putting any code inside table_for data, I already get the error:

undefined method `to_key' for ["Acquisition (website or newsletter opt-ins)", "3"]:Array

如何使用数组的数据,以把它们一个标准table_for内与我的基本列目标/的交易号?

How can I use the array's data to put them inside a standard table_for with my basic columns "goal"/"number of deals"?

我可能会在AA上一票,说这也许是不可能的偶然:的https:/ /github.com/gregbell/active_admin/issues/1713

I might have stumbled upon a ticket on AA that says it might not be possible: https://github.com/gregbell/active_admin/issues/1713

请问有人知道如何做到这一点?

Would anybody know how to do that?

推荐答案

我刚开了一个拉请求中添加此功能:的 https://github.com/gregbell/active_admin/pull/2812

I just opened a pull request to add this functionality: https://github.com/gregbell/active_admin/pull/2812

它可以让你在一个表中使用任意数据,如:

Which lets you use arbitrary data in a table, like this:

table_for foo: 1, bar: 2 do
  column :foo
  column :bar
end

请通过把这个在你的Gemfile给拉请求的尝试:

Please give the pull request a try by putting this in your Gemfile:

gem 'activeadmin', github: 'seanlinsley/active_admin',
                   branch: 'feature/1713-support_arbitrary_objects_for_tables'

更新

这已经被合并到主:

UPDATE

This has now been merged into master:

gem 'activeadmin', github: 'gregbell/active_admin'

这篇关于错误未定义的方法`TO_KEY'[XXX]:尝试使用主动联系table_for阵列数据时,阵列(Rails的,PostgreSQL中,postgres_ext宝石)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆