Im using active admin and when i export to csv json or xml. I get all results rather than checked results. Could anyone help me fix this.
So my Order.rb file for active admin is.
ActiveAdmin.register Order do
scope :not_completed_orders
action_item :add do
link_to "Get Manifest", "/admin/orders.csv"
end
index do
selectable_column
column :id
column :user
column :name
column :delivery_name
column :complete
column :delivery_address1
column :service
column :insurance
actions
end
csv do
column :name
column :delivery_name
column :id
end
# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
#
# or
#
permit_params do
permitted = [:email ,:country ,:city ,:postcode, :address_line_2, :address_line_1 ,:user_id, :name, :delivery_name, :company_name, :delivery_address1, :delivery_address2, :delivery_address3, :delivery_city, :delivery_postcode, :delivery_country, :phone, :package_contents, :description_content, :restricted_items, :terms_conditions, :insurance, :contents_value, :cf_reference, :reference_number, :complete]
permitted
end
end
# completed_at
When i click get manifest or export to csv in active admin. I wish to get the checked results. Rather than all of the results.
The ActiveAdmin download links are only exporting all entries.
But you can pass a filter with the selected ids via a batch action:
batch_action :export do |ids|
redirect_to "/admin/orders.csv?q[id_in][]=" + ids.join("&q[id_in][]=")
end
NOTE: keep in mind that the URL can be to long for a request with to many selected items.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With