0

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" ` 
Community
  • 1
  • 1
  • Could be the URL you're using doesn't match the route definition, can you post your routes for this method? – Matt Mar 21 '13 at 13:41
  • 1
    are you trying to grab the current user information? If so do `@user = current _user`. – coletrain Mar 21 '13 at 14:00

1 Answers1

0

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.

Robin Fisher
  • 1,454
  • 1
  • 13
  • 23
  • Yes I get that.. >_< I am using CanCan. Like Matt suggested I should be doing @user = current_user. Thank you as well Robin. Should really be Matts answer. If you could upvote him too. –  Mar 21 '13 at 14:12