Created
September 13, 2021 20:09
-
-
Save Rynaro/a64a0dad7c1664464fde88bc22aa121d to your computer and use it in GitHub Desktop.
View component from Rails Mailers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hi, <%= @me %> | |
This is a email from Component |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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