Question

I have WickedPDF working in my application and am trying to add the PDF as an attachment. I have seen the following SO question Rails 3 -Render PDF from view and attach to email and was following the answer from Unixmonkey. I have the following set up:

Controller

 def overtime
    @hospital_bookings = HospitalBooking.scoped
    hospital_booking = @hospital_bookings
    @user = User.find(params[:id])

I believe the above should work according to the SO question. However I am getting ActiveRecrod::RecordNotFound - Couldn't find User without an ID.

Updates

routes

`get "overtime" => "hospital_bookings#overtime", :as => "overtime" ` 
Was it helpful?

Solution

On the following line in your controller:

@user = User.find(params[:id])

You don't appear to be passing an id parameter in your route. Depending on your authentication model, you'll need to use current_user or pass an id to your route.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top