Rails best practices of using layouts

Suganya

I have two classes that derive from ActionMailer. But the deisgn template for both of them are going to be the same. I am going to use layouts. What I have done now is

In Reminder class

Class Reminders < ActionMailer::Base
  layouts :mailer_template
end

In Alert class

Class Alerts < ActionMailer::Base
  layouts :mailer_template
end

In layouts I have mailer_template.html

Another way I have is to create two layouts called reminders.html and alerts.html and as they both share the same code I can have a partial called _mailer_template.html and render this partial in bith the classes.

Now which is the best practice to use here?

Igor Guzak

as for me: you don't need create unnecessary files reminders.html, alerts.html, _shared_partial.html just use layouts :layout_name. Even If in future you will need separate layouts you will be able to do this (but now you don't need it).

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Best practices on using sudo in a bash script

분류에서Dev

How to write to Excel using MVC and EF Code First - Best Practices

분류에서Dev

How to write to Excel using MVC and EF Code First - Best Practices

분류에서Dev

Audio synthesis best practices

분류에서Dev

Gatsbyjs Page generation | Best practices

분류에서Dev

best approach and practices to handle exceptions in Spring?

분류에서Dev

Passing Fragment some variable best practices

분류에서Dev

Best practices Boolean vs Integer in SQL

분류에서Dev

Repository pattern interfaces- Best practices?

분류에서Dev

What are the best practices for including CSS and JavaScript in a page?

분류에서Dev

Best practices for installing ubuntu alongside Windows 10

분류에서Dev

Overlapping layouts using fragment transaction android

분류에서Dev

accessing multi endpoints web services (ASMX) best practices in c#

분류에서Dev

Best practices to benchmark deep models on CPU (and not GPU) in PyTorch?

분류에서Dev

node.js & express - global modules & best practices for application structure

분류에서Dev

Best practices for keeping EC2 Ubuntu machines updated

분류에서Dev

angularjs service calling $location.path is it against best practices?

분류에서Dev

Rails app: best way to only have admin user, no other user

분류에서Dev

What is the best way to calculate difference between TIMESTAMP values in Ruby on Rails

분류에서Dev

Whats the best way to create a self-referential association in Rails 4?

분류에서Dev

Swift Best Practices-API로 작업 할 때 인터넷 연결 및 404를 확인하는 방법 /시기

분류에서Dev

Net :: SMTPAuthenticationError using Rails ActionMailer

분류에서Dev

Update ActiveRecord using row in Rails

분류에서Dev

Using wrong namespace in the Rails controller

분류에서Dev

android listviews matching layouts

분류에서Dev

Android layouts size and resize

분류에서Dev

Best parse tree given spans using maximum sum

분류에서Dev

Best way to do an if else block using values within Javascript arrays?

분류에서Dev

What is the best practice using Dynamically generated forms or html imput tags

Related 관련 기사

  1. 1

    Best practices on using sudo in a bash script

  2. 2

    How to write to Excel using MVC and EF Code First - Best Practices

  3. 3

    How to write to Excel using MVC and EF Code First - Best Practices

  4. 4

    Audio synthesis best practices

  5. 5

    Gatsbyjs Page generation | Best practices

  6. 6

    best approach and practices to handle exceptions in Spring?

  7. 7

    Passing Fragment some variable best practices

  8. 8

    Best practices Boolean vs Integer in SQL

  9. 9

    Repository pattern interfaces- Best practices?

  10. 10

    What are the best practices for including CSS and JavaScript in a page?

  11. 11

    Best practices for installing ubuntu alongside Windows 10

  12. 12

    Overlapping layouts using fragment transaction android

  13. 13

    accessing multi endpoints web services (ASMX) best practices in c#

  14. 14

    Best practices to benchmark deep models on CPU (and not GPU) in PyTorch?

  15. 15

    node.js & express - global modules & best practices for application structure

  16. 16

    Best practices for keeping EC2 Ubuntu machines updated

  17. 17

    angularjs service calling $location.path is it against best practices?

  18. 18

    Rails app: best way to only have admin user, no other user

  19. 19

    What is the best way to calculate difference between TIMESTAMP values in Ruby on Rails

  20. 20

    Whats the best way to create a self-referential association in Rails 4?

  21. 21

    Swift Best Practices-API로 작업 할 때 인터넷 연결 및 404를 확인하는 방법 /시기

  22. 22

    Net :: SMTPAuthenticationError using Rails ActionMailer

  23. 23

    Update ActiveRecord using row in Rails

  24. 24

    Using wrong namespace in the Rails controller

  25. 25

    android listviews matching layouts

  26. 26

    Android layouts size and resize

  27. 27

    Best parse tree given spans using maximum sum

  28. 28

    Best way to do an if else block using values within Javascript arrays?

  29. 29

    What is the best practice using Dynamically generated forms or html imput tags

뜨겁다태그

보관