Put_flash for local page

I’m trying to flash an error, but I realized that put_flash/3 only works if I call either push_redirect/2 or push_patch/2. But what if I want to put_flash without redirecting or patching to another page. I want to display it there.

Is there any way how to do this?

The only way I can think of is to use push_redirect/2, and use the route with helper function from Routes. So far, it works, but would be nice if there’s another way of put the flash without the push_redirect.

You can use a simple notice variable in assigns, acting like a flash message.

See this post.

1 Like