I have a very "basic" issue, simple to explain but hard to solve.
On my homepage, I show a user the number of times he saw the page we can call Alpha.
<div>
<%= link_to "page alpha",
page_alpha_path(deal) %> <br/>
You have seen this page alpha #{deal.number_of_times_viewed} times
</div>
It works. but I 'd like to be able to do the following for example:
- user goes on homepage and sees the link and can read "You have seen this page alpha 4 times times already"
- he clicks on the alpha page link and arrive and alpha page
- he presses Chrome's 'Back button' and sees now 'You have seen this page alpha 5 times
As you see even on 'press back' the page has reloaded the number of times, it has triggered a call to the database table to recheck the number of times he saw the page.
Today unfortunately, whatever I tried, he still sees "4 times"
How to do it? Can I do it in pure Ruby/Rails or might I need some javascript or gon Watch ? or maybe some Rails UJS?