Part One:
This is my controller action –
def update
respond_to do |format|
if @user.update(user_params)
format.turbo_stream { redirect_to user_url(@user), notice: "User was successfully updated." }
else
...
end
end
end
The alert notice works, it also shows the correct @user updates, but if you click on any link or use the back button to the index page or edit page, the @user updates are not correct. It shows the cached version of the @user.
Is there something I am missing to make sure the index page and the edit page show the @user updates?
There is no turbo code on the index, edit or show pages.
Part two:
If I change the turbo stream update action to this –
format.turbo_stream { redirect_to users_url, notice: "User was successfully updated." }
Or this –
format.turbo_stream { redirect_to edit_user_url(@user), notice: "User was successfully updated." }
The redirect works but the @user is not updated, it shows the previous cache of the @user and the notice alert also does’t work.
Why does the redirect only update the @user on the show page and not the edit and index pages?
Why does the alert notice only work on the show page?
The result I am looking for is for the update action to show the notice alert and for all pages to show the updated @user regardless of where the redirect is going.
Thanks