0

Here, the view will be "test_email.html" as default.

def test_email(data)
  notif_type = data['notif_type']
  emails_list = ['[email protected]', '[email protected]']
  subject = case notif_type
  when 'test_case_1'
    "test1"
  when 'test_case_2'
    "test2"
  when 'test_case_3'
    "test3"
  mail(:to => emails_list, :subject => subject) do |format|
    format.html { render  :layout => 'layouts/newdesign' }
  end
end

What I want is as follows: for test_case_3, render "test_case_3.html" for the rest, render "test_email" as default How could I achieve it?

1 Answer 1

1
def test_email(data)
  notif_type = data['notif_type']
  emails_list = ['[email protected]', '[email protected]']
  @template = 'test_email'
  subject = case notif_type
    when 'test_case_3'
      @template = 'test_case_3.html'
      "test3"
    when 'test_case_1'
      "test1"
    when 'test_case_2'
      "test2"
    end
  mail(:to => emails_list, :subject => subject) do |format|
      format.html {render template: @template, :layout => 'layouts/newdesign' }
  end
end
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.