Ask A Question

Notifications

You’re not receiving notifications from this thread.

Attaching file to email Active Storage

Stephen Sizer asked in Rails

Hi Guys,

I am trying to attach a pdf to an email via active storage. Here is my code below and the error I am getting.

class Assignment < ApplicationRecord
has_one_attached :upload
belongs_to :user
belongs_to :course
belongs_to :lesson

after_save :send_notifications

def send_notifications
AssignmentMailer.notify_user(user).deliver_later
AssignmentMailer.notify_team(user, upload).deliver_later
end
end

ERROR:
No such file or directory @ rb_sysopen - /rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBFQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--889c8cda6fbfb3c827ff5bcd7a4ca7ff1594a37e/weekend.pdf

Thanks,
Steve

Reply

Changed to _url and not get this error:

Unsupported argument type: ActiveStorage::Attached::One
Extracted source (around line #35):

def send_notifications
AssignmentMailer.notify_user(user).deliver_later
-- AssignmentMailer.notify_team(user, upload).deliver_later ---
end
end

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 85,376+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.