Reputation: 168
I have a rails app with mildly 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 want to also customize the layout of the csv file download. 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, clicking the CSV link doesn't do anything in the browser. I'm running the app locally with foreman and it shows the following errors after I click on 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>'
Seems like that first error line might be the key, but I'm not sure which symbol it's referring to. What am I doing wrong?
Upvotes: 3
Views: 1118
Reputation: 2960
Try this:
...
column("Referrer") { |user| user.referrer }
column :referral_code
column("Created at") { |user| user.created_at }
...
Upvotes: 1