Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

[PATCH] For Rails 2.3 stable. Add layout override option to ActionMailer

#3200

There's current no way override a layout for a given action mailer action. With actioncontroller, you can always explicitly set :layout in a render call, but many times you are using the default :render with actionmailer. Following the actionmailer pattern of using accessors, I've added a new accessor for setting the layout of an action. I've attached the patch for the 2-3-stable branch. Let me know if you'd like a patch for master, but right now all of the unit test for layouts are broken, so I'm sure it's in flux right now.

ExampleMailer < ActionMailer::Base
layout "default"

def example(recipient)

recipients recipient
subject    "You have a mail"
from       "tester@example.com"
layout     "other"

end end

Reported by Scott Windsor · September 14th, 2009 @ 08:23 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Scott Windsor
    Scott Windsor
    • Tag changed from action_mailer to 2-3-stable, 2.3, action_mailer

    September 14th, 2009 @ 08:23 PM

  2. Scott Windsor
    Scott Windsor
    • Tag changed from 2-3-stable, 2.3, action_mailer to 2-3-stable, 2.3, action_mailer, patch

    September 14th, 2009 @ 09:06 PM

  3. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from 2-3-stable, 2.3, action_mailer, patch to 2-3-stable, 2.3, action_mailer, bugmash, patch

    September 25th, 2009 @ 12:12 PM

  4. Blue Box Jesse
    Blue Box Jesse

    +1

    Logic for the feature makes sense and allows for easy clean up of Action Mailer templates.

    Patch applies successfully to 2.3.0.

    Only concern is the test no longer checks that the old formatting works. Would it be worth while to have two tests?

    September 26th, 2009 @ 09:52 PM

  5. Scott Windsor
    Scott Windsor

    Jesse, do you know why the old test are broken? If so, I don't mind fixing them.

    September 26th, 2009 @ 11:08 PM

  6. Anuj Dutta
    Anuj Dutta

    +1 - for the idea.

    The tests aren't broken on 2-3-stable.

    September 26th, 2009 @ 11:55 PM

  7. sr.iniv.t
    sr.iniv.t

    +1 verified.

    The idea is nice addition. The patch applies cleanly on 2-3-stable and tests pass.

    September 27th, 2009 @ 07:10 PM

  8. Elad Meidar
    Elad Meidar

    +1 verified on Master and 2-3-stable, -1 on patch.... i'd rather to have a new test as Jesse suggested, rather than replacing the existing one.

    September 27th, 2009 @ 07:15 PM

  9. Scott Windsor
    Scott Windsor

    Makes sense to me. Here's the new patch with new unit tests. Thanks for the feedback!

    September 27th, 2009 @ 08:28 PM

  10. Anuj Dutta
    Anuj Dutta

    Got errors on applying the patch to 2-3-stable.

    September 27th, 2009 @ 10:43 PM

  11. Scott Windsor
    Scott Windsor

    andhap, could you add the errors you got?

    September 28th, 2009 @ 01:23 AM

  12. Anuj Dutta
    Anuj Dutta
    error: patch failed: actionmailer/lib/action_mailer/base.rb:354
    error: actionmailer/lib/action_mailer/base.rb: patch does not apply
    error: patch failed: actionmailer/test/mail_layout_test.rb:14
    error: actionmailer/test/mail_layout_test.rb: patch does not apply
    

    On 2-3-stable

    September 28th, 2009 @ 09:57 AM

  13. Scott Windsor
    Scott Windsor

    Look like there have been commits since my last patch. Here's the lastest one - let me know if it works for you now.

    September 28th, 2009 @ 04:24 PM

  14. Anuj Dutta
    Anuj Dutta

    Nope same error message. May be someone else should verify it as well because I have applied several patches and my fork is ahead of yours probably.

    September 28th, 2009 @ 06:12 PM

  15. Scott Windsor
    Scott Windsor

    Try applying on a clean 2-3-stable branch and see if it applies cleanly.

    September 29th, 2009 @ 03:24 AM

  16. Scott Windsor
    Scott Windsor

    any update? this is still working good for me. Who should I contact to review this?

    November 30th, 2009 @ 07:47 AM

  17. Anuj Dutta
    Anuj Dutta

    I will apply it to the current 2-3-stable branch today and let you know the outcome.

    November 30th, 2009 @ 08:02 AM

  18. Anuj Dutta
    Anuj Dutta

    I applied it and it does not give me any errors now. Hope it helps.

    November 30th, 2009 @ 08:10 AM

  19. Rizwan Reza
    Rizwan Reza
    • Tag changed from 2-3-stable, 2.3, action_mailer, bugmash, patch to 2-3-stable, 2.3, action_mailer, patch

    February 12th, 2010 @ 12:46 PM

  20. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open
    • Tag changed from 2-3-stable, 2.3, action_mailer, patch to 2-3-stable, 23, action_mailer, patch
    • Importance changed from to

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:55 PM

  21. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:55 PM

  22. swindsor
    swindsor

    This isn't a bugfix, it's a feature request. I'm trying to help the rails team out by providing new functionality. It's for rails 2-3-stable, not rails 3.

    February 2nd, 2011 @ 07:24 PM