def csv_download
      filename    = sprintf("%s-%s.csv",
                        model_name,
                        Time.now.strftime("%Y%m%d-%H%M%S"))
      file        = Tempfile.new(filename, Settings.edgarj.csv_dir)
      csv_visitor = EdgarjHelper::CsvVisitor.new(view_context)
      file.write CSV.generate_line(model.columns.map{|c| c.name})
      for rec in user_scoped.where(page_info.record.conditions).
          order(
            page_info.order_by.blank? ?
              nil :
              page_info.order_by + ' ' + page_info.dir) do
        array = []
        for col in model.columns do
          array << csv_visitor.visit_column(rec, col)
        end
        file.write CSV.generate_line(array)
      end
      file.close 
      File.chmod(Settings.edgarj.csv_permission, file.path)
      send_file(file.path, {
          type:     'text/csv',
          filename: filename})
     #file.close(true)
    end
def csv_download
      filename    = sprintf("%s-%s.csv",
                        model_name,
                        Time.now.strftime("%Y%m%d-%H%M%S"))
      file        = Tempfile.new(filename, Settings.edgarj.csv_dir)
      csv_visitor = EdgarjHelper::CsvVisitor.new(view_context)
      file.write CSV.generate_line(model.columns.map{|c| c.name})
      for rec in user_scoped.where(page_info.record.conditions).
          order(
            page_info.order_by.blank? ?
              nil :
              page_info.order_by + ' ' + page_info.dir) do
        array = []
        for col in model.columns do
          array << csv_visitor.visit_column(rec, col)
        end
        file.write CSV.generate_line(array)
      end
      file.close 
      File.chmod(Settings.edgarj.csv_permission, file.path)
      send_file(file.path, {
          type:     'text/csv',
          filename: filename})
     #file.close(true)
    end
zip -> address completion

 === INPUTS
 params[:zip]::          key to find address info. hyphen is supported.
 params[:adrs_prefix]::  address fields DOM id prefix. e.g. 'org_adrs_0_'

 === call flow
 ==== on drawing
   EdgarjHelper.draw_adrs()       app/helpers/edgarj_helper.rb
                                 app/views/edgarj/_address.html.erb
       Example:
           :
       <input type=text name='org[adrs_0_zip]'>
           :

 ==== on clicking zip->address button
   Edgarj.zip_complete()          public/javascripts/edgarj.js
    Ajax.Request()
     EdgarjController.zip_complete  app/controllers/edgarj_controller.rb
      inline RJS to fill address info

=begin
    def zip_complete
      zip           = params[:zip].gsub(/\D/, '')
      @address      = ZipAddress.find_by_zip(zip) || ZipAddress.new(
                        :prefecture => '?',
                        :city       => '',
                        :other      => '')

      # sanitize
      @adrs_prefix  = params[:adrs_prefix].gsub(/[^a-zA-Z_0-9]/, '')
    end
=end
 download model under current condition

 <tt>respond_to...format.csv</tt> approach was not used since
 \@list is different as follows:
 * csv returns all of records under the conditions
 * HTML returns *just* in specified 'page'.

 === Permission
 ModelPermission::READ on this controller is required.

 FIXME: file.close(true) deletes files *BEFORE* actually send file
 so that comment it out.  Need to clean these work files.