In my html.erb views I can normally use code like:
if current_user.role?(:label)
"do something"
end
I’m trying to do the same in a Prawn based PDF but am getting a “undefined local variable or method `current_user'” error.
I understand I need to explicitly include a helper in my PDF class, something like:
class SalesnotePdf < Prawn::Document
include CanCan::Ability
"do pdf layout here"
end
But this doesn’t appear to work? Any ideas on the correct include or other approach to this?
Thanks in advance!
EDIT:
I think current_user is actually a Devise method I need to access.
Well,
current_userreally is a Devise method and is available in views, helpers and controllers, but not models. A better approach would be to check the user’s role in a controller and then call a specific Prawn document.