3
我有一個輕度定製的ActiveAdmin表註冊用戶的Rails應用程序。 app/admin/users.rb看起來像這樣:在activeadmin中自定義csv格式禁用csv下載鏈接
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
這個按預期工作。但我也想自定義csv文件下載的佈局。因此,我在最後一個末尾添加此塊:
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
添加後,單擊CSV鏈接在瀏覽器中不執行任何操作。我跟工頭本地運行的應用程序後,我點擊它顯示了以下錯誤:
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>'
好像是第一個錯誤行可能是關鍵的,但我不知道它是指哪個符號至。我究竟做錯了什麼?
它的工作原理!應該注意,儘管如此,'{| user | user.referrer}'outputs#。爲了使輸出在該列中有用,我使用了以下內容:'column(「Referrer」){| user |如果!user.referrer.nil? user.referrer [:email] end}' –
m2bn
2014-09-11 02:40:53