I have an android app and a rails app. When a order is made from android, it calls create order API in rails app. So whenever a create order is successful in rails app,i want to perform a print action that prints the order bill using the data send from the android.
But the controller i created only gives a response either in json or html format. i.e
class API::V1::OrdersController << Api::ApiController
def create
@order = Order.create(
item: params[:item],
quantity: params[:quantity],
price: params[:price]
)
if @order.persisted?
respond_to do |format|
format.json { notice: 'Order successfully created.' }
format.html { render :print }
end
end
end
end
This will only give back the response of 'Order successfully created.' when json is used or the html format page written in 'print.html.slim' to the android. But i want to print a order bill page from 'print.html.slim' when a order is persisted.
print.html.slim
table.table
thead
th Item Name
th Quantity
th Price
tbody
tr
td = @order.item
td = @order.quantity
td = @order.price
Is there any way i can do this ?