activeadmin: belongs_to association freezes rails app on index page

I have a pretty simple setup and it seems that while accessing an associations FK and directing them to the show page for it works fine, including it as a belongs_to causes the active_admin index page to lock up. My code is quite simple - basically businesses have matches:

class Business < ActiveRecord::Base
  has_many :matches
end

class Match < ActiveRecord::Base
  belongs_to :business
end

My rails app freezes when the matches index page is hit but if I remove the belongs_to association, I can access match['business_id'] just fine. To help rule out errors on my end, I removed all of my index page code so I literally just have those models and code to register them. To be explicit, when I say freeze, I mean my Thin server hangs, nothing is spit out to log file, and I have to kill the ruby process. I don’t have a lot of data in my matches table and I’ve waited the length of writing this post (10 mins) to see if anything different happened after a long time.

I’m using Postgres, on Rails 3.2.12, and ActiveAdmin 0.6.0

My schema is

db=# \d matches;
                                                  Table "public.matches"
               Column                |            Type             |                      Modifiers                       
-------------------------------------+-----------------------------+------------------------------------------------------
 id                                  | integer                     | not null default nextval('matches_id_seq'::regclass)
 business_id                         | integer                     | not null
 provider_name                       | character varying(255)      | not null
 provider_business_id                | character varying(255)      | not null
Indexes:
    "matches_pkey" PRIMARY KEY, btree (id)
    "matches_business_id_provider_mongo_table_provider_entry_id_idx" UNIQUE, btree (business_id, provider_name, provider_business_id)
    "index_matches_on_business_id" btree (business_id)
Check constraints:
    "non_empty_provider_entry" CHECK (provider_business_id::text <> ''::text)
    "non_empty_provider_table" CHECK (provider_name::text <> ''::text)

And the relevant part of Gemfile.lock is:

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (3.2.12)
      actionpack (= 3.2.12)
      mail (~> 2.4.4)
    actionpack (3.2.12)
      activemodel (= 3.2.12)
      activesupport (= 3.2.12)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.4)
      rack (~> 1.4.5)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.2.1)
    activeadmin (0.6.0)
      arbre (>= 1.0.1)
      bourbon (>= 1.0.0)
      devise (>= 1.1.2)
      fastercsv
      formtastic (>= 2.0.0)
      inherited_resources (>= 1.3.1)
      jquery-rails (>= 1.0.0)
      kaminari (>= 0.13.0)
      meta_search (>= 0.9.2)
      rails (>= 3.0.0)
      sass (>= 3.1.0)
    activemodel (3.2.12)
      activesupport (= 3.2.12)
      builder (~> 3.0.0)
    activerecord (3.2.12)
      activemodel (= 3.2.12)
      activesupport (= 3.2.12)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activeresource (3.2.12)
      activemodel (= 3.2.12)
      activesupport (= 3.2.12)
    activesupport (3.2.12)
      i18n (~> 0.6)
      multi_json (~> 1.0)
    arbre (1.0.1)
      activesupport (>= 3.0.0)
    arel (3.0.2)
    bcrypt-ruby (3.0.1)
    bourbon (3.1.2.1)
      sass (>= 3.2.0)
      thor
    bson (1.8.5)
    bson_ext (1.8.5)
      bson (~> 1.8.5)
    builder (3.0.4)
    coffee-rails (3.2.2)
      coffee-script (>= 2.2.0)
      railties (~> 3.2.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.6.2)
    daemons (1.1.9)
    devise (2.2.3)
      bcrypt-ruby (~> 3.0)
      orm_adapter (~> 0.1)
      railties (~> 3.1)
      warden (~> 1.2.1)
    erubis (2.7.0)
    eventmachine (1.0.3)
    execjs (1.4.0)
      multi_json (~> 1.0)
    fastercsv (1.5.5)
    formtastic (2.2.1)
      actionpack (>= 3.0)
    has_scope (0.5.1)
    hike (1.2.2)
    i18n (0.6.4)
    inherited_resources (1.4.0)
      has_scope (~> 0.5.0)
      responders (~> 0.9)
    journey (1.0.4)
    jquery-rails (2.2.1)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    json (1.7.7)
    kaminari (0.14.1)
      actionpack (>= 3.0.0)
      activesupport (>= 3.0.0)
    mail (2.4.4)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    meta_search (1.1.3)
      actionpack (~> 3.1)
      activerecord (~> 3.1)
      activesupport (~> 3.1)
      polyamorous (~> 0.5.0)
    mime-types (1.22)
    mongo (1.8.5)
      bson (~> 1.8.5)
    multi_json (1.7.2)
    orm_adapter (0.4.0)
    pg (0.15.1)
    polyamorous (0.5.0)
      activerecord (~> 3.0)
    polyglot (0.3.3)
    rack (1.4.5)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-ssl (1.3.3)
      rack
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (3.2.12)
      actionmailer (= 3.2.12)
      actionpack (= 3.2.12)
      activerecord (= 3.2.12)
      activeresource (= 3.2.12)
      activesupport (= 3.2.12)
      bundler (~> 1.0)
      railties (= 3.2.12)
    railties (3.2.12)
      actionpack (= 3.2.12)
      activesupport (= 3.2.12)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (>= 0.14.6, < 2.0)
    rake (10.0.4)
    rdoc (3.12.2)
      json (~> 1.4)
    responders (0.9.3)
      railties (~> 3.1)
    sass (3.2.7)
    sass-rails (3.2.6)
      railties (~> 3.2.0)
      sass (>= 3.1.10)
      tilt (~> 1.3)
    sprockets (2.2.2)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    thin (1.5.1)
      daemons (>= 1.0.9)
      eventmachine (>= 0.12.6)
      rack (>= 1.0.0)
    thor (0.18.1)
    tilt (1.3.7)
    treetop (1.4.12)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.37)
    uglifier (2.0.1)
      execjs (>= 0.3.0)
      multi_json (~> 1.0, >= 1.0.2)
    warden (1.2.1)
      rack (>= 1.0)

PLATFORMS
  ruby

DEPENDENCIES
  activeadmin
  bson_ext
  coffee-rails (~> 3.2.1)
  jquery-rails
  meta_search (>= 1.1.0.pre)
  mongo
  pg
  rails (= 3.2.12)
  sass-rails (~> 3.2.3)
  thin
  uglifier (>= 1.0.3)

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 69 (42 by maintainers)

Most upvoted comments

found it!

By default, when loading an index for a class that belongs_to another class, the filters sidebar includes a dropdown wherein you can filter by parent. The dropdown is populated using a SELECT "parent_class".* FROM "parent_class" query, loading every single instance of the parent class, which isn’t really sensible for a large database. We can solve the problem by specifying different filters, but I’d recommend changing the default filter behavior to make activeadmin work out-of-the-box with large databases.