Custom page in ActiveAdmin
It is a cheatsheet. I created it to bookmark working solution, because it's kind of rare encountered.
ActiveAdmin.register_page 'CustomPage' do
menu parent: "Main"
content do
count = SomeModel.count
render partial: 'admin/custompage/upload_form', locals: {count: count}
end
page_action :import, method: :post do
imported = Import.new(params[:file].path)
imported.import
redirect_to admin_custompage_path, notice: "Imported #{imported.element_count}."
end
end
h2 Import XML
h3
' Total:
b= count
= form_tag(admin_custompage_import_path, multipart: true) do
= file_field_tag 'file', required: 'required'
= submit_tag 'Upload', name: nil
Written by Denis Savitskiy
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#