Setting csv format in activeadmin disables csv download link

I have a rails application with a slightly customized ActiveAdmin table of registered users. app / admin / users.rb looks like this:

ActiveAdmin.register User do
  actions :index, :show

  preserve_default_filters!
  filter :referrer, collection: User.all.map{ |user| [user.email, user.id] }
  filter :referrals, collection: User.all.map{ |user| [user.email, user.id] }

  index do 
    column :id
    column("Name")              { |user| user.first_name + " " + user.last_name }
    column :email
    column("Referrer", :referrer, :sortable => :referrer_id)
    column :referral_code
    column("Created at", :created_at, :sortable => :created_at)
    column("Referral count")    { |user| user.referrals.count }
    actions
  end
end

      

This works as expected. But I also want to customize the csv file upload layout. So I add this block right before the last end:

  csv do 
    column :id
    column("Name")        { |user| user.first_name + " " + user.last_name }
    column :email
    column("Referrer", :referrer)
    column :referral_code
    column("Created at", :created_at)
    column("Referral count")  { |user| user.referrals.count }
  end

      

After adding this link click the CSV does nothing in the browser. I run the application locally using the wizard and it shows the following errors after clicking the link:

08:58:12 web.1    | E, [2014-09-10T08:58:12.818820 #4610] ERROR -- : app error: no implicit conversion of Symbol into Hash (TypeError)
08:58:12 web.1    | E, [2014-09-10T08:58:12.818937 #4610] ERROR -- : /Users/maxnorton/.bundler/ruby/2.0.0/active_admin-bf9dabe6a568/lib/active_admin/csv_builder.rb:41:in `merge'
08:58:12 web.1    | E, [2014-09-10T08:58:12.818999 #4610] ERROR -- : /Users/maxnorton/.bundler/ruby/2.0.0/active_admin-bf9dabe6a568/lib/active_admin/csv_builder.rb:41:in `column'
08:58:12 web.1    | E, [2014-09-10T08:58:12.819059 #4610] ERROR -- : /Users/maxnorton/Documents/dev/prelaunchr/app/admin/users.rb:23:in `block (2 levels) in <top (required)>'
08:58:12 web.1    | E, [2014-09-10T08:58:12.819116 #4610] ERROR -- : /Users/maxnorton/.bundler/ruby/2.0.0/active_admin-bf9dabe6a568/lib/active_admin/csv_builder.rb:59:in `instance_exec'
08:58:12 web.1    | E, [2014-09-10T08:58:12.819176 #4610] ERROR -- : /Users/maxnorton/.bundler/ruby/2.0.0/active_admin-bf9dabe6a568/lib/active_admin/csv_builder.rb:59:in `exec_columns'
08:58:12 web.1    | E, [2014-09-10T08:58:12.819233 #4610] ERROR -- : /Users/maxnorton/.bundler/ruby/2.0.0/active_admin-bf9dabe6a568/lib/active_admin/csv_builder.rb:46:in `build'
08:58:12 web.1    | E, [2014-09-10T08:58:12.819289 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/actionpack-4.1.4/lib/action_dispatch/http/response.rb:95:in `each'
08:58:12 web.1    | E, [2014-09-10T08:58:12.819363 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/actionpack-4.1.4/lib/action_dispatch/http/response.rb:95:in `each'
08:58:12 web.1    | E, [2014-09-10T08:58:12.819421 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/actionpack-4.1.4/lib/action_dispatch/http/response.rb:95:in `each'
08:58:12 web.1    | E, [2014-09-10T08:58:12.819477 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/actionpack-4.1.4/lib/action_dispatch/http/response.rb:50:in `each'
08:58:12 web.1    | E, [2014-09-10T08:58:12.819534 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/body_proxy.rb:31:in `each'
08:58:12 web.1    | E, [2014-09-10T08:58:12.819591 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/body_proxy.rb:31:in `each'
08:58:12 web.1    | E, [2014-09-10T08:58:12.819654 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/body_proxy.rb:31:in `each'
08:58:12 web.1    | E, [2014-09-10T08:58:12.819712 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/body_proxy.rb:31:in `each'
08:58:12 web.1    | E, [2014-09-10T08:58:12.819767 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/body_proxy.rb:31:in `each'
08:58:12 web.1    | E, [2014-09-10T08:58:12.819822 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/body_proxy.rb:31:in `each'
08:58:12 web.1    | E, [2014-09-10T08:58:12.819876 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/body_proxy.rb:31:in `each'
08:58:12 web.1    | E, [2014-09-10T08:58:12.819931 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/lint.rb:647:in `each'
08:58:12 web.1    | E, [2014-09-10T08:58:12.819987 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/body_proxy.rb:31:in `each'
08:58:12 web.1    | E, [2014-09-10T08:58:12.820042 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/chunked.rb:23:in `each'
08:58:12 web.1    | E, [2014-09-10T08:58:12.820100 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_response.rb:60:in `http_response_write'
08:58:12 web.1    | E, [2014-09-10T08:58:12.820193 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:586:in `process_client'
08:58:12 web.1    | E, [2014-09-10T08:58:12.820252 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:670:in `worker_loop'
08:58:12 web.1    | E, [2014-09-10T08:58:12.820307 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:525:in `spawn_missing_workers'
08:58:12 web.1    | E, [2014-09-10T08:58:12.820362 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:140:in `start'
08:58:12 web.1    | E, [2014-09-10T08:58:12.820417 #4610] ERROR -- : /Library/Ruby/Gems/2.0.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'
08:58:12 web.1    | E, [2014-09-10T08:58:12.820471 #4610] ERROR -- : /usr/bin/unicorn:23:in `load'
08:58:12 web.1    | E, [2014-09-10T08:58:12.820525 #4610] ERROR -- : /usr/bin/unicorn:23:in `<main>'

      

It looks like the first line of the error might be the key, but I'm not sure what character it refers to. What am I doing wrong?

+3


source to share


1 answer


Try the following:



...
column("Referrer")  { |user| user.referrer }
column :referral_code
column("Created at")  { |user| user.created_at }
...

      

+1


source







All Articles