I have a form for user to subscribe to news letter, all it does is collect email and then return to the home page but I want to show alert on the homepage that the process was a success or failure. All I can come up with is using context and #if tag but how do I inject context with redirect(:to)
@mannguyen you could use a query item in the URL which you can pick up in your request handler, similar to how the login failed warning is shown in the book
Thank you. I was able to follow the login failed warning in the book to achieved what I want. However, that was only for when it failed. But when it success how would you handle the alert. Because right now if in the context i just set the error to false and in my leaf template I listen to if error false show success and if error is true show failure alert. Then my success alert would show 100% of the time.
You can have a success bool in your context that is set if a flag is set in the query, basically the opposite of what you do for error. There’s no reason you can’t do both