title: Refresh All Information On Back Button Press: Ruby on Rails
body: <p>My RoR website implements a calendar using the <code>fullcalendar</code> gem. Each user has a calendar that shows the events which he or she is attending. The following scenario sets the stage for my question:</p>
  
  <ol>
  <li>User Alice clicks an event on her calendar, which leads to the event's <code>show</code> page.</li>
  <li>Alice clicks the 'unattend event' button on the event's <code>show page</code></li>
  <li>Alice clicks the back button.</li>
  <li>The event that she just unattended is still listed on her calendar.</li>
  </ol>
  
  <p>How can I make the browser refresh Alice's event information, so that only events that she is currently attending are displayed, when the back button is pressed?</p>
  
  <p>I've scoured Stack Overflow and not found a working solution. Cache clearing as seen here <a href="https://stackoverflow.com/questions/711418/how-to-prevent-browser-page-caching-in-rails">How to prevent browser page caching in Rails</a> did not work. I'm not even sure this is a caching problem. Perhaps there is some javascript that will force information to be reloaded? Any solutions are much appreciated. Thanks!</p>
  
  <p>In response to @ElliottRoche:</p>
  
  <p>The attend button is clicked in the view, triggering the attend action:</p>
  
  <pre><code>&lt;%= button_to button_text, attend_event_path(@event), :remote =&gt; true,  :id =&gt; "attend" %&gt;
  </code></pre>
  
  <p>The attend action adds/removes the attendee from the list of attendees as follows:</p>
  
  <pre><code> def attend
  
      @event = Event.find(params[:id])
      @attendee = User.find(session[:user_id])
  
      if @event.users.exclude?(@attendee)
        @event.users &lt;&lt; @attendee
        @event.save
  
      else
        @event.users.delete(@attendee)
      end
  
      @attendees = @event.users
  
  
      respond_to do |format|
        format.js
        format.html {  }
        format.json { }
      end
  end
  </code></pre>
  
  <p>With attend.js.erb, the attendees list is updated using UJS:</p>
  
  <pre><code>$('#attendees-list').html("&lt;%= j render(:partial =&gt; 'attendees_list', :locals =&gt; { :attendees =&gt; @attendees }) %&gt;");
  </code></pre>
  
  <p>From here, when the back-button is pressed, the fact that the user has attended/unattended the event is not reflected.</p>