How to call a method in the view that returns a pdf to the user?

0

I created a small script to consume my API, in Ruby.

require 'http'

data = 
response = HTTP.get("http://localhost:9292/api/boleto", :params => {:type => 'pdf', :bank => 'blabla', :data=> '{...}'}) 

puts response.body # retorna um objeto representando a resposta

puts response.code # retorna o código HTTP da resposta, e.g. 404, 500, 200

Basically it puts a pdf within date, which is generated by the application.

I'm trying to generate a small view, which runs the function and consumes the api at the click of a button, and downloads it to the user. (I do not want to pass anything to api, I already know how to do) If possible show an example with scaffold or some rails generate. How do I create this button with these features in my index.html.erb?

    
asked by anonymous 06.04.2018 / 16:20

0 answers