ruby on rails - How to build a form that on submit sends back a file to the end user -


i'm building form on submit needs send user file download.

my form:

<form method="get" action="/data_export" class="form-horizontal">     <input id="user_current_password" type="password" class="input" name="user[current_password]">     <button class="btn btn-primary" type="submit">download</button> </form> 

controller:

  def index         send_data group.to_csv(@groups),                   :type => 'text/csv; charset=utf-8; header=present',                    :disposition => "attachment; filename=groups.csv"   end 

the problem when submitting form, page redirects page text. not trigger download of file. how can form submit cause file download?

thanks


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -