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.

Flash convenience methods "notice" and "alert" should also be available for FlashNow

#4369

Hi,

I guess the title describes it already pretty well. I think that for consistency, a FlashNow object should also have the same convenience methods as a Flash object has. In my mind a FlashNow object is the same as a Flash object, only that it isn't around for the next action, but has the same behavior.

So instead of

Flash.notice = "Saved"
Flash.now[:notice] = "Saved"

I can write

Flash.notice = "Saved"
Flash.now.notice = "Saved"

Reported by Helmut Juskewycz · April 12th, 2010 @ 11:06 AM

State: resolved
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. linki
    linki
    • Tag changed from flash, rails3 to flash, patch, rails3

    I like the idea and created a patch to add that behaviour.

    I added:

    flash.now.alert=(message)
    flash.now.notice=(message)

    It's my first patch I ever created for the rails source, so if I did anything wrong, please tell me.

    April 15th, 2010 @ 06:23 PM

  2. Rizwan Reza
    Rizwan Reza
    • Milestone cleared.
    • State changed from new to verified
    • Assigned user set to Yehuda Katz (wycats)

    +1 Applies cleanly.

    May 15th, 2010 @ 08:36 AM

  3. Josh Kalderimis
    Josh Kalderimis

    +1 But could you make some tests for this linki, this makes sure the functionality stays consistent

    May 15th, 2010 @ 08:46 AM

  4. Rizwan Reza
    Rizwan Reza

    There are no tests for flash there from before, so I think this is good to go. Or may be we should go about adding tests for flash completely.

    May 15th, 2010 @ 10:21 AM

  5. Rizwan Reza
    Rizwan Reza
    • Tag changed from flash, patch, rails3 to bugmash, flash, patch, rails3

    May 15th, 2010 @ 10:21 AM

  6. José Valim
    José Valim

    Please do improve the test suite!

    May 15th, 2010 @ 10:23 AM

  7. Rizwan Reza
    Rizwan Reza
    • Assigned user changed from Yehuda Katz (wycats) to Rizwan Reza

    May 15th, 2010 @ 10:31 AM

  8. Anil Wadghule
    Anil Wadghule

    I've attached a patch with necessary tests.

    May 15th, 2010 @ 03:26 PM

  9. PacoGuzman
    PacoGuzman

    I've attached a patch with the accessors and necessary test

    May 15th, 2010 @ 03:48 PM

  10. PacoGuzman
    PacoGuzman

    Nopw with the patch already attached. upss!

    May 15th, 2010 @ 03:49 PM

  11. Anil Wadghule
    Anil Wadghule

    I've attached a patch with necessary tests.

    May 15th, 2010 @ 03:50 PM

  12. PacoGuzman
    PacoGuzman

    Forget my comments, excuse me!

    May 15th, 2010 @ 03:53 PM

  13. Repository
  14. Michael Raidel
    Michael Raidel

    just wanted to upload patch for ticket 4369 and recognized that there is already an applied patch. But the patch doesn't include all accessors from the original flash and is also a little unDRY so I am attaching my patch nevertheless.

    May 15th, 2010 @ 04:27 PM

  15. Michael Raidel
    Michael Raidel

    I've attached a patch. This one only include the tests I wrote. Both tests essentially test the same thing.

    May 15th, 2010 @ 04:42 PM

  16. Michael Raidel
  17. José Valim
    José Valim
    • State changed from resolved to open
    • Assigned user changed from Rizwan Reza to José Valim

    May 15th, 2010 @ 04:59 PM

  18. linki
    linki

    Michael's code looks better but the question is do we need getters for "flash.now.notice" and "flash.now.alert"?

    You'll never use "flash.now.notice" in any view, you only use "flash.notice" and either it survived the last request or it didn't depending on whether you set it through flash or flash.now

    but it might be helpful in a controller..

    May 15th, 2010 @ 07:44 PM

  19. José Valim
    José Valim
    • State changed from open to resolved

    @linki this is a good point! Let's leave as it is!

    May 15th, 2010 @ 08:14 PM

  20. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Low

    October 15th, 2010 @ 11:01 PM