Last week we had our science fair at the Flatiron School. It was nerve wracking, but an awesome and fun experience. The week prior was grueling. Whilst spending hours with my team building our app, I noticed something interesting about notices and errors.
The first place I rendered a notice was in the Sessions Controller. It was plain and simple, no problem.
1 2 3 4 | |
Great! Onto the next message, an error in my Landings Controller:
1 2 3 4 5 6 7 8 9 | |
But wait, this notice did not render. The render method doesn’t take an alert/notice/error hash entry like the redirect_to method does. So, how do we make a flash appear on “render”?
1 2 3 4 5 6 7 8 9 10 | |
Not too much hassel. We had to add one extra line before the render - flash.now. This makes the notice render on the current page.