Skip to content

Instantly share code, notes, and snippets.

@Rynaro
Created September 13, 2021 20:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rynaro/a64a0dad7c1664464fde88bc22aa121d to your computer and use it in GitHub Desktop.
Save Rynaro/a64a0dad7c1664464fde88bc22aa121d to your computer and use it in GitHub Desktop.
View component from Rails Mailers
# frozen_string_literal: true
class ComponentMailer < ApplicationMailer
def notify(me)
mail to: 'henrique@mail.com', subject: 'Component', body: ApplicationController.render(MyComponent.new(me: me))
end
end
Hi, <%= @me %>
This is a email from Component
# frozen_string_literal: true
class MyComponent < ViewComponent::Base
def initialize(me:)
@me = me
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment