I successfully uploaded a file to S3 and now I want to attach file to email, so i can send it by using Gmail API. Some people suggested to call method .file
directly like here
as you can see, you can call method
<%= @page.form.file.filename %>
.file
directly from form.
here is my mount uploader
class:
class Crm::LogEmailAttachment < Asset
belongs_to :owner, class_name: 'Crm::LogEmail'
mount_uploader :data, Crm::LogEmailAttachmentUploader
mount_base64_uploader :data, Crm::LogEmailAttachmentUploader
# default_scope -> {order("assets.order")}
def to_s
self.data.try(:file).try(:filename)
end
end
and here is my erb form:
<div class="document-wrap">
<%= log_email.fields_for :crm_log_email_attachments do |a| %>
<%= a. file_field :data, input_html: {class: "form-control" , wrapper: 'field'}, label: false %>
<% end %>
</div>
then I try to get file by just calling .file
from params[:data]
it returns undefined method file
for #<ActionDispatch::Http::UploadedFile:0x007fc337322290>
, my question is how can I get the path of the file and filename from carrierwave
?