I am new to rails and I am trying to use Prawm to generate pdf's. I am getting this error: ActionController::UnknownFormat
Here is the code:
def show_deposited_checks
deposit_id = params[:format]
if deposit_id.present?
@payments = Payment.where(:deposit_id => deposit_id)
respond_to do |format|
format.html
format.pdf do
pdf = Prawn::Document.new
pdf.text "Hello World"
send_data pdf.render
end
end
else
@payments = Payment.all.limit(10)
end
end
I an redirecting from here:
redirect_to show_deposited_checks_payments_path(deposit)
I have another method that works just fine so I suspect it has something to do with the redirect and the way the controller is receiving the data. Any help with be greatly appreciated.
I think the problem is that where doesn't execute immediately. There's probably a better way(I'm fairly new to Rails too), but I think this should work:
@payments = Payment.where(:deposit_id => deposit_id).take(10) #or how ever many you want included
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.