Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can i override a layout? #109

Open
GabrielLyonB opened this issue Jul 18, 2023 · 1 comment
Open

Can i override a layout? #109

GabrielLyonB opened this issue Jul 18, 2023 · 1 comment

Comments

@GabrielLyonB
Copy link

GabrielLyonB commented Jul 18, 2023

Hello, i think this might be something basic that i am not understanding.

I got a mailer like this:

class OrderMailer < ApplicationMailer
  layout 'mjml_layout'
  
  def created
    # some logic here
    mail(to: emails, subject: '')
  end
  
  ...
  # like the created method i got another 5 methods
  ...
  
  # i want another layout here
  def another_method
    # some logic
    mail(to: emails, subject: '') do |format|
      format.mjml { render: 'new_mjml_layout }
    end
  end
end

This is not working. Clearly i am doing something wrong. I want to only override the general mjml_layout for the one method, in this example the another_method.
I tried overriding the general layout like a controller using 'new_mjml_layout', only: [:another_method] and 'mjml_layout', except: [:another_method] but that didn't work either.
What am i doing wrong? This is no how it works? This just can't be done?

@sighmon
Copy link
Owner

sighmon commented Jul 20, 2023

@GabrielLyonB If you want help it'd be great for you to create a sample project for the community to clone and debug.

FYI here's how I use it in my project:

  def email_special
    respond_to do |format|
      format.text { render layout: false }
      format.mjml { render layout: false }
    end
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants