title: Rails - How to download .pdf file using Grape API
body: <p>In rails 4, I am using <code>grape</code> gem for mobile app features. In mobile app, I need to provide download <code>.pdf</code> file option. I have referred this <a href="https://stackoverflow.com/questions/16641388/how-to-allow-binary-file-download-using-grape-api#answer-19898620">How to allow Binary File download using GRAPE API</a> but file is not generating here.</p>
  
  <p>Other than mobile app(in web side) I have downloading a file using,</p>
  
  <pre><code>file_path = "#{Rails.root}/public/downloads/#{@user.id}_guide.pdf"
  pdf = WickedPdf.new.pdf_from_string(render_to_string('public/guide/template', :layout=&gt; false))
  File.open(file_path, 'wb') do |file|
    file &lt;&lt; pdf
  end
  return file_path
  </code></pre>
  
  <p>Please help me to write an API which generates and downloads a <code>.pdf</code> file</p>