2015-05-29 2 views
0

Здесь будет отображаться «test_email.html» по умолчанию.визуализировать разные виды в рельсах

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 

То, что я хочу, это выглядит следующим образом: для test_case_3, штукатурка «test_case_3.html» для отдыха, штукатурка «test_email» по умолчанию Как я могу добиться этого?

ответ

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 
Смежные вопросы