Skip to content

Instantly share code, notes, and snippets.

@fahadgudu
Forked from maxivak/00.md
Last active August 29, 2015 14:08
Show Gist options
  • Save fahadgudu/9a2de617a53992b8cc4c to your computer and use it in GitHub Desktop.
Save fahadgudu/9a2de617a53992b8cc4c to your computer and use it in GitHub Desktop.
controller do
..
def import
@product = Product.find(params[:id])
# access uploaded file - params[:file]
# do the job
# redirect
redirect_to showimport_admin_product_path(@product), :notice=>'Imported'
end
end
action_item do
link_to "Do smth", dosmth_admin_products_path
end
collection_action :dosmth, :method => :get do
end
controller do
...
def dosmth
# do some stuff
# shows view '/admin/products/dosmth.html.haml'
#render 'dosmth'
end
end
ActiveAdmin.register Product do
index :as => :table do
column :title
column :price
actions
end
end
ActiveAdmin.register Product do
...
member_action :showimport, :method=>:get do
end
member_action :import, :method=>:post do
end
controller do
def showimport
@product = Product.find(params[:id])
end
def import
# renders view 'app/views/admin/products/showimport.html.haml'
end
end
end
%h2 Import
= form_tag(import_admin_product_path(@product), method: "post", multipart: true) do |f|
Field1:
= text_field_tag 'field1'
%br
%input(type="file" name="file" placeholder="File")
%br
= submit_tag "Upload"
%br
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment