Sha256: 3c62fea503022a96a5b64db906eac457b8e141f586dee5860cd162324c1c235f

Contents?: true

Size: 896 Bytes

Versions: 1

Compression:

Stored size: 896 Bytes

Contents

class Notifier < ActionMailer::Base
  default :from => 'noreply@company.com'
  # default :from => "Didier Leser - CESAM Nature <didier.leser@cesam-nature.com>"

  def instructions(user)
    @user = user

    # normal syntax
    xlsx = render handlers: [:axlsx], template: 'users/mailers/instructions', layout: false

    # using render_to_string. sometimes not available, but why??
    # xlsx = render_to_string handlers: [:axlsx], template: 'users/mailers/instructions', layout: false

    # creating own view
    # av = ActionView::Base.new()
    # av.view_paths = ActionController::Base.view_paths
    # av.extend ApplicationHelper
    # av.assign user: @user
    # xlsx = av.render handlers: [:axlsx], template: "users/mailers/instructions"
    
    attachments["user_#{user.id}.pdf"] = {mime_type: Mime::XLSX, content: xlsx}
    mail :to => user.email, :subject => 'Instructions'
  end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axlsx_rails-0.1.5 spec/dummy/app/mailers/notifier.rb