在erb视图中不显示API响应

时间:2014-04-06 19:18:11

标签: ruby api sinatra

我正在点击API并收到成功的回复。我正在将响应写入终端,但我似乎无法将响应写入我的erb文件。

// api.rb

def print(html)
  @print_response = @printer.post("/api/v1/queue/add/html/#{@printer_id}", :body => { :data => html })
end

// app.rb

if @customer_order
  printer_erb = ERB.new(File.read(File.join(File.dirname(__FILE__), "views", "printer", "order.erb")))
  printer = Mprinter.new(@venue.printer_id)
  printer_html = printer_erb.result(binding)

  puts printer_html.inspect

  @print_response = printer.print(printer_html).body
  puts @print_response

end

  redirect "/orders/#{@order.id}"
end

// order.erb

<div class="alert alert-warning" style="margin-top: 10px">
  <%= @print_response %>
</div>

0 个答案:

没有答案